Integrating The Normal Probability Density Function

135 ビュー (過去 30 日間)
John hope
John hope 2017 年 10 月 15 日
コメント済み: Star Strider 2017 年 10 月 16 日
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.

採用された回答

Star Strider
Star Strider 2017 年 10 月 15 日
編集済み: Star Strider 2017 年 10 月 15 日
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 件のコメント
John hope
John hope 2017 年 10 月 16 日
Much appreciated answer accepted.
Thanks again.
Star Strider
Star Strider 2017 年 10 月 16 日
As always, my pleasure.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by