I'm using the plot the probability density function:
y = zeros(1,10000);
for j=1:10000
r = rand(100,1);
for i=1:100
y(j) = y(j) + r(i) - 0.5;
end
y(j) = y(j)/sqrt(100);
end
[n,x] = hist(y,100);
plot(x,n/10000/diff(x(1:2)));
hold on;
However I'd also like to print the theoretical too. The best I seem to have managed is the following:
plot(x,normpdf(x,0,1),'r');
But this doesn't follow the actual at all. What am I missing here? Here's what my plots look like at the moment. The blue is the actual and the red is the theoretical.
plot(x,normpdf(x,0,1/pi),'r');
– Maksim Gorkiy