Integrating The Normal Probability Density Function
    29 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    John hope
 le 15 Oct 2017
  
    
    
    
    
    Commenté : Star Strider
      
      
 le 16 Oct 2017
            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 commentaires
Réponse acceptée
  Star Strider
      
      
 le 15 Oct 2017
        
      Modifié(e) : Star Strider
      
      
 le 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 commentaires
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur MATLAB Support for MinGW-w64 C/C++ Compiler dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

