%% Generate Gaussian Distributed Random Numbers
% Generate Gaussian distributed random numbers using uniformly distributed random numbers. To convert a uniformly distributed random number x to a Gaussian distributed random number y, use the transform
% y = \sqrt{2} \rm{erf^{-1}}(x).
% Note that because x has the form -1 + 2*rand(1,10000), you can improve accuracy by using erfcinv instead of erfinv. For details, see Tips.
% Generate 10,000 uniformly distributed random numbers on the interval [-1,1]. Transform them into Gaussian distributed random numbers. Show that the numbers follow the form of the Gaussian distribution using a histogram plot.

rng('default')
x = -1 + 2*rand(1,10000);
y = sqrt(2)*erfinv(x);
h = histogram(y);

% Copyright 2015 The MathWorks, Inc.