Integrating The Normal Probability Density Function

26 views (last 30 days)
Hello community
I was wondering if the community could help me with integration with Matlab.
I am new to matlab so my apologies for the "basic" question.
I have a set of data from which I have calculated the:-
• Mean = 1853.910 • Standard Deviation = 1.829
I want to integrate the normpdf function in Matlab from x = 1855.739 to x = 1852.081 however I am getting silly results, I should be getting an approx value of 68.26%.
I have searched the Matlab directory and found the normpdf M file and amended it so it now looks like:-
y = exp(-0.5 * ((x - 1853.910)./1.829).^2) ./ (sqrt(2*pi) .* 1.829);
Where I have replaced the variables MU and SIGMA with 1853.910 and 1.829.
I cannot seem to integrate this function from x = 1855.739 to x = 1852.081.
Can anyone help?
Its driving me nuts.
Thank you.

Accepted Answer

Star Strider
Star Strider on 15 Oct 2017
Edited: Star Strider on 15 Oct 2017
The normcdf function will do the integration for you:
Mean = 1853.910;
Standard_Deviation = 1.829;
lims = [1855.739 1852.081];
cp = normcdf(lims, Mean, Standard_Deviation);
Prob = cp(1) - cp(2)
Prob =
0.6826895
EDIT
If you want to do the integration yourself, this works:
p = @(x,m,s) exp(-((x-m).^2)/(2*s.^2)) / (s*sqrt(2*pi));
c = integral(@(x) p(x, Mean, Standard_Deviation), 1852.081, 1855.739);
The result is the same as ‘Prob’.
  6 Comments
John hope
John hope on 16 Oct 2017
Much appreciated answer accepted.
Thanks again.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!