From Wikipedia:

“In probability theory, the expected value of a random variable, intuitively, is the long-run average value of repetitions of the experiment it represents.”

I decided to give it a try in MATLAB.

% Expected Value of a Die numOfIterations = 100000; meanArray = zeros([1 numOfIterations]); values = zeros([1 numOfIterations]); for i = 1:numOfIterations % Get a random value between the range of [1 6] values(i) = randi(6); % Calculate the mean so far meanArray(i) = mean(values(1:i)); end %Plot plot(1:numOfIterations, meanArray); % Display the latest calculated mean disp(meanArray(end));

This is the result:

Advertisements