how to calculate the normal distribution in matlab

To calculate the normal distribution in MATLAB, you can make use of the normpdf function, which takes the following arguments:

main.m
y = normpdf(x, mu, sigma)
26 chars
2 lines

where x is a vector of values for which you want to calculate the probability density function, mu is the mean of the distribution, and sigma is the standard deviation.

For example, if you want to calculate the probability of a value x = 2 from a normal distribution with mu = 0 and sigma = 1, you can use the following code:

main.m
x = 2;
mu = 0;
sigma = 1;
y = normpdf(x, mu, sigma);
53 chars
5 lines

The output y will be the probability density function for the given x, mu, and sigma.

gistlibby LogSnag