%% Random Numbers from Normal Distribution with Specific Mean and Variance
%% Section 1
% First, initialize the random number generator to make the results in this example repeatable.

rng(0,'twister');

%
% Create a vector of 1000 random values drawn from a normal distribution with a mean of 500 and a standard deviation of 5.

a = 5;
b = 500;
y = a.*randn(1000,1) + b;

%
% Calculate the sample mean, standard deviation, and variance.

stats = [mean(y) std(y) var(y)]

% The mean and variance are not 500 and 25 exactly because they are calculated from a sampling of the distribution.
% Copyright 2012 The MathWorks, Inc.