Program to implement Standard Normal Distribution in MATLAB
Hello Readers,
If you want to understand what is Standard Normal Distribution then have a look at this video. This also includes the implementation of this using MATLAB online compiler.
CODE
Here is the code to implement Standard Normal Distribution in the MATLAB
You can copy the code directly and paste in the script file of the MATLAB (or MATLAB's online compiler) and run it.. It will work fine:
%x=mean+sqrt(var)*randn(r,c)
%for standard normal deviation mean is zero and variance is 1
n=100000;
norm_mean=1;
norm_var=2;
x=norm_mean+sqrt(norm_var)*randn(1,n);
% sqrt(norm_var) is standard deviation
nob=10;
a=min(x);
b=max(x);
aa=linspace(a,b,nob);% linspace is linearly spaced vector
count(size(aa))=0;
y(size(aa-1))=0;
for i=1:length(aa)-1
for j=1:length(x)
if x(j) >= aa(i) && x(j) < aa(i+1)
count(i)=count(i)+1;
end
end
y(i)=((aa(i)+aa(i+1))/2);
end
%plotting
o=y;
p=count(1:end)/n;
%(o,p);
bar(o,p);
ConversionConversion EmoticonEmoticon