Main Content

var

Variance of probability distribution

Description

example

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

Examples

collapse all

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.

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

Create a triangular distribution object.

pd = makedist('Triangular','A',-3,'B',1,'C',3)
pd = 
  TriangularDistribution

A = -3, B = 1, C = 3

Compute the variance of the distribution.

v = var(pd)
v = 1.5556

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

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

Fit a kernel distribution object to the data.

pd = fitdist(x,'Kernel')
pd = 
  KernelDistribution

    Kernel = normal
    Bandwidth = 3.61677
    Support = unbounded

Compute the variance of the fitted distribution.

v = var(pd)
v = 88.4893

Input Arguments

collapse all

Probability distribution, specified as one of the probability distribution objects in this table.

Distribution ObjectFunction or App to Create Probability Distribution Object
BetaDistributionmakedist, fitdist, Distribution Fitter
BinomialDistributionmakedist, fitdist, Distribution Fitter
BirnbaumSaundersDistributionmakedist, fitdist, Distribution Fitter
BurrDistributionmakedist, fitdist, Distribution Fitter
ExponentialDistributionmakedist, fitdist, Distribution Fitter
ExtremeValueDistributionmakedist, fitdist, Distribution Fitter
GammaDistributionmakedist, fitdist, Distribution Fitter
GeneralizedExtremeValueDistributionmakedist, fitdist, Distribution Fitter
GeneralizedParetoDistributionmakedist, fitdist, Distribution Fitter
HalfNormalDistributionmakedist, fitdist, Distribution Fitter
InverseGaussianDistributionmakedist, fitdist, Distribution Fitter
KernelDistributionfitdist, Distribution Fitter
LogisticDistributionmakedist, fitdist, Distribution Fitter
LoglogisticDistributionmakedist, fitdist, Distribution Fitter
LognormalDistributionmakedist, fitdist, Distribution Fitter
LoguniformDistributionmakedist
MultinomialDistributionmakedist
NakagamiDistributionmakedist, fitdist, Distribution Fitter
NegativeBinomialDistributionmakedist, fitdist, Distribution Fitter
NormalDistributionmakedist, fitdist, Distribution Fitter
PiecewiseLinearDistributionmakedist
PoissonDistributionmakedist, fitdist, Distribution Fitter
RayleighDistributionmakedist, fitdist, Distribution Fitter
RicianDistributionmakedist, fitdist, Distribution Fitter
StableDistributionmakedist, fitdist, Distribution Fitter
tLocationScaleDistributionmakedist, fitdist, Distribution Fitter
TriangularDistributionmakedist
UniformDistributionmakedist
WeibullDistributionmakedist, fitdist, Distribution Fitter

Output Arguments

collapse all

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

Extended Capabilities

Introduced in R2013a