Documentation Center

  • Trial Software
  • Product Updates

cdf

Class: prob.TruncatableDistribution
Package: prob

Cumulative distribution function of probability distribution object

Syntax

y = cdf(pd,x)
y = cdf(pd,x,'upper')

Description

y = cdf(pd,x) returns the cumulative distribution function (cdf) of the probability distribution pd at the values in x.

y = cdf(pd,x,'upper') returns the complement of the cumulative distribution function (cdf) of the probability distribution pd at the values in x, using an algorithm that more accurately computes the extreme upper tail probabilities.

Input Arguments

expand all

pd — Probability distributionprobability distribution object

Probability distribution, specified as a probability distribution object. Create a probability distribution object with specified parameter values using makedist. Alternatively, for fittable distributions, create a probability distribution object by fitting it to data using fitdist or the Distribution Fitting app.

x — Values at which to calculate cdfarray

Values at which to calculate the cdf, specified as an array.

Data Types: single | double

upper — Upper tail probability flag'upper'

Upper tail probability flag, specified as 'upper'. If you specify 'upper', then cdf returns the complement of the cdf of pd, using an algorithm that more accurately computes the extreme upper tail probabilities.

Output Arguments

expand all

y — Cumulative distribution functionarray

Cumulative distribution function of the specified probability distribution, evaluated at the values in x, returned as a array. y has the same dimensions as x.

Examples

expand all

Plot Standard Normal Distribution cdf

Create a standard normal distribution object.

pd = makedist('Normal')
pd = 

  NormalDistribution

  Normal distribution
       mu = 0
    sigma = 1

Specify the x values and compute the cdf.

x = -3:.1:3;
cdf_normal = cdf(pd,x);

Plot the cdf of the standard normal distribution.

plot(x,cdf_normal,'LineWidth',2)

Plot Gamma Distribution cdf

Create three gamma distribution objects. The first uses the default parameter values. The second specifies a = 1 and b = 2. The third specifies a = 2 and b = 1.

pd_gamma = makedist('Gamma')
pd_gamma = 

  GammaDistribution

  Gamma distribution
    a = 1
    b = 1
pd_12 = makedist('Gamma','a',1,'b',2)
pd_12 = 

  GammaDistribution

  Gamma distribution
    a = 1
    b = 2
pd_21 = makedist('Gamma','a',2,'b',1)
pd_21 = 

  GammaDistribution

  Gamma distribution
    a = 2
    b = 1

Specify the x values and compute the cdf for each distribution.

x = 0:.1:5;
cdf_gamma = cdf(pd_gamma,x);
cdf_12 = cdf(pd_12,x);
cdf_21 = cdf(pd_21,x);

Create a plot to visualize how the cdf of the gamma distribution changes when you specify different values for the shape parameters a and b.

figure;
J = plot(x,cdf_gamma)
hold on;
K = plot(x,cdf_gamma_12,'r--')
L = plot(x,cdf_gamma_21,'k-.')
set(J,'LineWidth',2);
set(K,'LineWidth',2);
legend([J K L],'a = 1, b = 1','a = 1, b = 2','a = 2, b = 1','Location','southeast');
hold off;

See Also

| | | | | |

Was this topic helpful?