Main Content

expcdf

Exponential cumulative distribution function

Description

example

p = expcdf(x) returns the cumulative distribution function (cdf) of the standard exponential distribution, evaluated at the values in x.

example

p = expcdf(x,mu) returns the cdf of the exponential distribution with mean mu, evaluated at the values in x.

example

[p,pLo,pUp] = expcdf(x,mu,pCov) also returns the 95% confidence interval [pLo,pUp] of p when mu is an estimate with variance pCov.

[p,pLo,pUp] = expcdf(x,mu,pCov,alpha) specifies the confidence level for the confidence interval [pLo pUp] to be 100(1–alpha)%.

example

___ = expcdf(___,'upper') returns the complement of the cdf, evaluated at the values in x, using an algorithm that more accurately computes the extreme upper-tail probabilities than subtracting the lower tail value from 1. 'upper' can follow any of the input argument combinations in the previous syntaxes.

Examples

collapse all

Compute the probability that an observation in the standard exponential distribution falls in the interval [1 2].

p = expcdf([1 2]);
p(2) - p(1)
ans = 0.2325

The median of the exponential distribution is µ*log(2).

Confirm the median by computing the cdf of µ*log(2) for several different choices of µ.

mu = 10:10:60; 
p = expcdf(log(2)*mu,mu)
p = 1×6

    0.5000    0.5000    0.5000    0.5000    0.5000    0.5000

The cdf of the mean is always equal to 1-1/e (~0.6321).

Confirm the result by computing the exponential cdf of the mean for means one through six.

mu = 1:6;
x = mu;
p = expcdf(x,mu)
p = 1×6

    0.6321    0.6321    0.6321    0.6321    0.6321    0.6321

Find a confidence interval estimating the probability that an observation is in the interval [0 1] using exponentially distributed data.

Generate a sample of 1000 random numbers drawn from the exponential distribution with mean 5.

rng('default') % For reproducibility
x = exprnd(5,1000,1);

Estimate the mean with a confidence interval.

[muhat,muci] = expfit(x)
muhat = 5.0129
muci = 2×1

    4.7161
    5.3387

Estimate the variance of the mean estimate.

[~,nCov] = explike(muhat,x)
nCov = 0.0251

Create the confidence interval estimating the probability an observation is in the interval [0 1].

[p,pLo,pUp] = expcdf(1,muhat,nCov);
pCi = [pLo; pUp]
pCi = 2×1

    0.1710
    0.1912

expcdf calculates the confidence interval using a normal approximation for the distribution of the log estimate of the mean. Compute a more accurate confidence interval for p by evaluating expcdf on the confidence interval muci.

pCi2 = expcdf(1,muci)
pCi2 = 2×1

    0.1911
    0.1708

The bounds pCi2 are reversed because a lower mean makes the event more likely and a higher mean makes the event less likely.

Determine the probability that an observation from the exponential distribution with mean 1 is in the interval [50 Inf].

p1 = 1 - expcdf(50,1)
p1 = 0

expcdf(50,1) is nearly 1, so p1 becomes 0. Specify 'upper' so that expcdf computes the extreme upper-tail probabilities more accurately.

p2 = expcdf(50,1,'upper')
p2 = 1.9287e-22

Input Arguments

collapse all

Values at which to evaluate the cdf, specified as a nonnegative scalar value or an array of nonnegative scalar values.

  • To evaluate the cdf at multiple values, specify x using an array.

  • To evaluate the cdfs of multiple distributions, specify mu using an array.

If either or both of the input arguments x and mu are arrays, then the array sizes must be the same. In this case, expcdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the cdf value of the distribution specified by the corresponding element in mu, evaluated at the corresponding element in x.

Example: [3 4 7 9]

Data Types: single | double

Mean of the exponential distribution, specified as a positive scalar value or an array of positive scalar values.

  • To evaluate the cdf at multiple values, specify x using an array.

  • To evaluate the cdfs of multiple distributions, specify mu using an array.

If either or both of the input arguments x and mu are arrays, then the array sizes must be the same. In this case, expcdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the cdf value of the distribution specified by the corresponding element in mu, evaluated at the corresponding element in x.

Example: [1 2 3 5]

Data Types: single | double

Variance of the estimate of mu, specified as a positive scalar value.

You can estimate mu from data by using expfit or mle. You can then estimate the variance of mu by using explike. The resulting confidence interval bounds are based on a normal approximation for the distribution of the log of the mu estimate. You can get a more accurate set of bounds by applying expcdf to the confidence interval returned by expfit. For an example, see Confidence Interval of Exponential cdf Value.

Example: 0.10

Data Types: single | double

Significance level for the confidence interval, specified as a scalar in the range (0,1). The confidence level is 100(1–alpha)%, where alpha is the probability that the confidence interval does not contain the true value.

Example: 0.01

Data Types: single | double

Output Arguments

collapse all

cdf values evaluated at x, returned as a scalar value or an array of scalar values. p is the same size as x and mu after any necessary scalar expansion. Each element in p is the cdf value of the distribution specified by the corresponding element in mu, evaluated at the corresponding element in x.

Lower confidence bound for p, returned as a scalar value or an array of scalar values. pLo has the same size as p.

Upper confidence bound for p, returned as a scalar value or an array of scalar values. pUp has the same size as p.

More About

collapse all

Exponential cdf

The exponential distribution is a one-parameter family of curves. The parameter μ is the mean.

The cdf of the exponential distribution is

p=F(x|u)=0x1μetμdt=1exμ.

The result p is the probability that a single observation from the exponential distribution with mean μ falls in the interval [0, x]. A common alternative parameterization of the exponential distribution is to use λ defined as the mean number of events in an interval as opposed to μ, which is the mean wait time for an event to occur. λ and μ are reciprocals.

For more information, see Exponential Distribution.

Alternative Functionality

  • expcdf is a function specific to the exponential distribution. Statistics and Machine Learning Toolbox™ also offers the generic function cdf, which supports various probability distributions. To use cdf, create an ExponentialDistribution probability distribution object and pass the object as an input argument or specify the probability distribution name and its parameters. Note that the distribution-specific function expcdf is faster than the generic function cdf.

  • Use the Probability Distribution Function app to create an interactive plot of the cumulative distribution function (cdf) or probability density function (pdf) for a probability distribution.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a