var
Variance of probability distribution
Syntax
Description
Examples
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 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
Variance of Triangular Distribution
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
Variance of a Kernel Distribution
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
pd
— Probability distribution
probability distribution object
Probability distribution, specified as one of the probability distribution objects in the following table.
Distribution Object | Function or App Used to Create Probability Distribution Object |
---|---|
BetaDistribution | makedist , fitdist , Distribution Fitter |
BinomialDistribution | makedist , fitdist ,
Distribution Fitter |
BirnbaumSaundersDistribution | makedist , fitdist ,
Distribution Fitter |
BurrDistribution | makedist , fitdist ,
Distribution Fitter |
ExponentialDistribution | makedist , fitdist ,
Distribution Fitter |
ExtremeValueDistribution | makedist , fitdist ,
Distribution Fitter |
GammaDistribution | makedist , fitdist ,
Distribution Fitter |
GeneralizedExtremeValueDistribution | makedist , fitdist ,
Distribution Fitter |
GeneralizedParetoDistribution | makedist , fitdist ,
Distribution Fitter |
HalfNormalDistribution | makedist , fitdist ,
Distribution Fitter |
InverseGaussianDistribution | makedist , fitdist ,
Distribution Fitter |
KernelDistribution | fitdist , Distribution Fitter |
LogisticDistribution | makedist , fitdist ,
Distribution Fitter |
LoglogisticDistribution | makedist , fitdist ,
Distribution Fitter |
LognormalDistribution | makedist , fitdist ,
Distribution Fitter |
LoguniformDistribution | makedist |
MultinomialDistribution | makedist |
NakagamiDistribution | makedist , fitdist ,
Distribution Fitter |
NegativeBinomialDistribution | makedist , fitdist ,
Distribution Fitter |
NormalDistribution | makedist , fitdist ,
Distribution Fitter |
PiecewiseLinearDistribution | makedist |
PoissonDistribution | makedist , fitdist ,
Distribution Fitter |
RayleighDistribution | makedist , fitdist ,
Distribution Fitter |
RicianDistribution | makedist , fitdist ,
Distribution Fitter |
StableDistribution | makedist , fitdist ,
Distribution Fitter |
tLocationScaleDistribution | makedist , fitdist ,
Distribution Fitter |
TriangularDistribution | makedist |
UniformDistribution | makedist |
WeibullDistribution | makedist , fitdist ,
Distribution Fitter |
Output Arguments
v
— Variance
nonnegative scalar value
Variance of the probability distribution, returned as a nonnegative scalar value.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
The input argument
pd
can be a fitted probability distribution object for beta, exponential, extreme value, lognormal, normal, and Weibull distributions. Createpd
by fitting a probability distribution to sample data from thefitdist
function. For an example, see Code Generation for Probability Distribution Objects.
For more information on code generation, see Introduction to Code Generation and General Code Generation Workflow.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2013a
See Also
std
| mean
| makedist
| fitdist
| Distribution Fitter
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)