MATLAB provides the normcdf
function to calculate the cumulative distribution function (CDF) of the normal distribution. The CDF gives the probability of getting a value less than or equal to a given value (i.e., the area under the curve to the left of the given value).
Here's an example:
main.m238 chars10 lines
This will output:
main.m21 chars2 lines
You can also use the normpdf
function to calculate the probability density function (PDF) of the normal distribution. The PDF gives the probability of getting a specific value (i.e., the height of the curve at the given value).
Here's an example:
main.m211 chars10 lines
This will output:
main.m20 chars2 lines
Note that the probability of getting a specific value in a continuous distribution like the normal distribution is actually zero, so the PDF gives the probability density instead.
gistlibby LogSnag