how to calculate cumulative distribution function in matlab

The cumulative distribution function (CDF) can be calculated in MATLAB using the cdf function from the Statistics and Machine Learning Toolbox.

The basic syntax for calculating the CDF is as follows:

main.m
y = cdf(type,x,param1,param2,...)
34 chars
2 lines

Here, type is a string scalar or character vector specifying the name of the probability distribution that you want to use. x is the vector of values at which to evaluate the CDF, and param1, param2, etc. are the parameters of the specified distribution.

For example, to calculate the CDF of a normal distribution with mean 0 and standard deviation 1 at the values -2, -1, 0, 1, and 2, you could use the following code:

main.m
mu = 0;     % mean
sigma = 1;  % standard deviation
x = -2:0.1:2; % values at which to evaluate the CDF
y = cdf('Normal',x,mu,sigma); % calculate the CDF
plot(x,y)   % plot the CDF
181 chars
6 lines

This code will generate a plot of the normal CDF at the specified values of x.

gistlibby LogSnag