expcdf - Exponential cumulative distribution function - MATLAB
Exponential cumulative distribution function
Syntax
Description
___ = 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)
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.
Estimate the variance of the mean estimate.
[~,nCov] = explike(muhat,x)
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]
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.
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].
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')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
xusing an array.To evaluate the cdfs of multiple distributions, specify
muusing 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
xusing an array.To evaluate the cdfs of multiple distributions, specify
muusing 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
The exponential distribution is a one-parameter family of curves. The parameter μ is the mean.
The cdf of the exponential distribution is
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
expcdfis a function specific to the exponential distribution. Statistics and Machine Learning Toolbox™ also offers the generic functioncdf, which supports various probability distributions. To usecdf, create anExponentialDistributionprobability distribution object and pass the object as an input argument or specify the probability distribution name and its parameters. Note that the distribution-specific functionexpcdfis faster than the generic functioncdf.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
Version History
Introduced before R2006a