# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

# 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

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.

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

Data Types: `single` | `double`

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

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

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) ```

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_12,'r--') L = plot(x,cdf_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; ```
```J = Line with properties: Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [1x51 double] YData: [1x51 double] ZData: [1x0 double] Use GET to show all properties K = Line with properties: Color: [1 0 0] LineStyle: '--' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [1x51 double] YData: [1x51 double] ZData: [1x0 double] Use GET to show all properties L = Line with properties: Color: [0 0 0] LineStyle: '-.' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [1x51 double] YData: [1x51 double] ZData: [1x0 double] Use GET to show all properties ```

## See Also

Was this topic helpful?

Download now