Integrating The Normal Probability Density Function
조회 수: 18 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!