MATLAB Answers

sphinx mo

Probability Density function plot

Asked by sphinx mo
on 4 Oct 2012


I have two value one is for mean and another Standard deviation. how i can plot PDF for it ?



No products are associated with this question.

1 Answer

Answer by Wayne King
on 4 Oct 2012
Edited by Wayne King
on 4 Oct 2012
 Accepted answer

That very much depends on the PDF. For some distributions, the mean itself is necessary and sufficient (like the exponential), for others the mean and standard deviation are necessary and sufficient (the Gaussian), and for still others the distribution is not parametrized by the mean and std. If this is Gaussian, then I'll assume mu is the mean and sigma the standard deviation.

   mu = 10; sigma = 1.5;
   x = mu-(4*sigma):0.01:mu+(4*sigma);
   y = normpdf(x,mu,sigma);

So basically you really need to know which PDF you have the first moment (mean) and second central moment (variance) of.


hy many thanks..

can you explain a little bit , what is meaning x = mu-(4*sigma):0.01:mu+(4*sigma);

Wayne King
on 4 Oct 2012

By assuming a Gaussian distribution, essentially all the probability is the mean plus/minus 3 standard deviations, so I just put an extra one (sigma) in there as a cushion. Any Gaussian function really has infinite support, but for all intents and purposes, you can characterize the PDF by just considering that interval.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!