The Integration of Gaussian PDF to obtain the CDF why don’t I get the correct answer?
Show older comments
I am trying to run a simulation, but before I do I wanted to write a simple program to ensure I could get a correct answer.
I start off by generating 10,000 long vector using a Normally distributed pseudorandom number generator (randn) with a mean =0 and sigma =1.
nsamples=100000; f=0 f=f+(1)*randn(nsamples,1);
x = f;
m = mean(f)
s = std(f)
I calculate the mean and std using the standard MATLAB functions (mean and std) verifying mean and sigma.
I then plot the data using the standard normal equation
f(x,m,s)=(e^-0.5*(x-m/s)^2)/s*sqrt(2pi)
where x is the RV, s=std deviation, and m is the mean.
I then integrate the PDF from -1 to 1 using the following commend
p1 = -.5 * ((x - m)/s) .^ 2;
p2 = (s * sqrt(2*pi));
G = exp(p1) ./ p2;
fun = @(x) G;
cdf=integral(fun,-1,1,'ArrayValued',true);
This generates another vector. So I calculate the mean of the CDF vector (cdfmean=mean(cdf)) and instead of getting something around 68% I get 56%
why?
Accepted Answer
More Answers (0)
Categories
Find more on Binomial Distribution in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!