how to calculate the probability of a normal distribution in matlab

To calculate the probability of a normal distribution in MATLAB, you can use the normcdf function, which stands for "normal cumulative distribution function". This function takes in three arguments: the value you want to calculate the probability of, the mean of the distribution, and the standard deviation of the distribution. The output of normcdf represents the area under the curve of the normal distribution to the left of the input value.

Here's an example:

main.m
% define the parameters of the normal distribution
mu = 0; % mean
sigma = 1; % standard deviation

% calculate the probability of x being less than 1
x = 1; % the value we want to find the probability of
prob = normcdf(x, mu, sigma);

% print the result
fprintf('The probability of x being less than %f is %f\n', x, prob);
323 chars
11 lines

This will output:

main.m
The probability of x being less than 1.000000 is 0.841345
58 chars
2 lines

This means that there's an 84.13% chance that a randomly drawn sample from this normal distribution will be less than 1.

gistlibby LogSnag