var

Class: prob.ToolboxFittableParametricDistribution
Package: prob

Variance of probability distribution object

Syntax

v = var(pd)

Description

v = var(pd) returns the variance v of the probability distribution pd.

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, create a probability distribution object by fitting it to data using fitdist or the Distribution Fitting app.

Output Arguments

expand all

v — Variancenonnegative scalar value

Variance of the probability distribution, returned as a nonnegative scalar value.

Examples

expand all

Variance of a Fitted Distribution

Load the sample data. Create a vector containing the first column of students' exam grade data.

load examgrades;
x = grades(:,1);

Fit a normal distribution object to the data.

pd = fitdist(x,'Normal')
pd = 

  NormalDistribution

  Normal distribution
       mu = 75.0083   [73.4321, 76.5846]
    sigma =  8.7202   [7.7391, 9.98843]

Compute the variance of the fitted distribution.

v = var(pd)
v =

   76.0419

For a normal distribution, the variance is equal to the square of the parameter sigma.

Variance of a Skewed Distribution

Create a Weibull probability distribution object.

pd = makedist('Weibull','a',5,'b',2)
pd = 

  WeibullDistribution

  Weibull distribution
    A = 5
    B = 2

Compute the variance of the distribution.

v = var(pd)
v =
    5.3650

See Also

| |

Was this topic helpful?