Mean of probability distribution
Load the sample data. Create a vector containing the first column of students’ exam grade data.
load examgrades
x = grades(:,1);Create a normal distribution object by fitting it 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 mean of the fitted distribution.
m = mean(pd)
m = 75.0083
The mean of the normal distribution is equal to the parameter mu.
Create a Weibull probability distribution object.
pd = makedist('Weibull','a',5,'b',2)
pd =
WeibullDistribution
Weibull distribution
A = 5
B = 2
Compute the mean of the distribution.
mean = mean(pd)
mean = 4.4311
Create a uniform distribution object
pd = makedist('Uniform','lower',-3,'upper',5)
pd =
UniformDistribution
Uniform distribution
Lower = -3
Upper = 5
Compute the mean of the distribution.
m = mean(pd)
m = 1
Load the sample data. Create a probability distribution object by fitting a kernel distribution to the miles per gallon (MPG) data.
load carsmall; pd = fitdist(MPG,'Kernel')
pd =
KernelDistribution
Kernel = normal
Bandwidth = 4.11428
Support = unbounded
Compute the mean of the distribution.
mean(pd)
ans = 23.7181
pd — Probability distributionProbability distribution, specified as a probability distribution object created using one of the following.
| Function or App | Description |
|---|---|
makedist | Create a probability distribution object using specified parameter values. |
fitdist | Fit a probability distribution object to sample data. |
| Distribution Fitter | Fit a probability distribution to sample data using the interactive Distribution Fitter app and export the fitted object to the workspace. |
m — MeanMean of the probability distribution, returned as a scalar value.
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. Create pd by fitting a probability distribution to
sample data from the fitdist 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.
Distribution Fitter | fitdist | makedist | median | std
You have a modified version of this example. Do you want to open this example with your edits?