# Documentation

### This is machine translation

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

# prob.TriangularDistribution class

Package: prob
Superclasses: prob.ParametricTruncatableDistribution

Triangular probability distribution object

## Description

`prob.TriangularDistribution` is an object consisting of parameters and a model description for a triangular probability distribution. Create a probability distribution object with specified parameters using `makedist`.

## Construction

`pd = makedist('Triangular')` creates a triangular probability distribution object using the default parameter values.

`pd = makedist('Triangular','a',a,'b',b,'c',c)` creates a triangular distribution object using the specified parameter values.

### Input Arguments

expand all

Lower limit for the triangular distribution, specified as a scalar value.

Data Types: `single` | `double`

Peak location for the triangular distribution, specified as a scalar value greater than or equal to `a`.

Data Types: `single` | `double`

Upper limit for the triangular distribution, specified as a scalar value greater than or equal to `b`.

Data Types: `single` | `double`

## Properties

expand all

Lower limit for the triangular distribution, stored as a scalar value.

Data Types: `single` | `double`

Location of the peak for the triangular distribution, stored as a scalar value greater than or equal to `a`.

Data Types: `single` | `double`

Upper limit for the triangular distribution, stored as a scalar value greater than or equal to `b`.

Data Types: `single` | `double`

Probability distribution name, stored as a character vector. This property is read-only.

Data Types: `char`

Logical flag for truncated distribution, stored as a logical value. If `IsTruncated` equals `0`, the distribution is not truncated. If `IsTruncated` equals `1`, the distribution is truncated. This property is read-only.

Data Types: `logical`

Number of parameters for the probability distribution, stored as a positive integer value. This property is read-only.

Data Types: `single` | `double`

Distribution parameter descriptions, stored as a cell array of character vectors. Each cell contains a short description of one distribution parameter. This property is read-only.

Data Types: `char`

Distribution parameter names, stored as a cell array of character vectors. This property is read-only.

Data Types: `char`

Distribution parameter values, stored as a vector. This property is read-only.

Data Types: `single` | `double`

Truncation interval for the probability distribution, stored as a vector containing the lower and upper truncation boundaries. This property is read-only.

Data Types: `single` | `double`

## Methods

### Inherited Methods

 cdf Cumulative distribution function of probability distribution object icdf Inverse cumulative distribution function of probability distribution object iqr Interquartile range of probability distribution object median Median of probability distribution object pdf Probability density function of probability distribution object random Generate random numbers from probability distribution object truncate Truncate probability distribution object
 mean Mean of probability distribution object std Standard deviation of probability distribution object var Variance of probability distribution object

## Definitions

### Triangular Distribution

The triangular distribution is frequently used in simulations when limited sample data is available. The lower and upper limits represent the smallest and largest values, and the location of the peak represents an estimate of the mode.

The triangular distribution uses the following parameters.

ParameterDescriptionSupport
`a`Lower limit$a\le b$
`b`Peak location$a\le b\le c$
`c`Upper limit$c\ge b$

The probability density function (pdf) is

`$f\left(x|a,b,c\right)=\left\{\begin{array}{c}\frac{2\left(x-a\right)}{\left(c-a\right)\left(b-a\right)}\text{ };\text{ }a\le x\le b\\ \frac{2\left(c-x\right)}{\left(c-a\right)\left(c-b\right)}\text{ };\text{ }bc\end{array}\text{ }.$`

and

`$f\left(x|a,b,c\right)=\frac{2\left(c-x\right)}{\left(c-a\right)\left(c-b\right)}\text{ };\text{ }b`

The value of the pdf is 0 when x < a or x > c.

## Examples

expand all

Create a triangular distribution object using the default parameter values.

`pd = makedist('Triangular')`
```pd = TriangularDistribution A = 0, B = 0.5, C = 1```

Create a triangular distribution object by specifying parameter values.

`pd = makedist('Triangular', 'a',-2,'b',1,'c',5)`
```pd = TriangularDistribution A = -2, B = 1, C = 5```

Compute the mean of the distribution.

`m = mean(pd)`
```m = 1.3333```