Main Content

gamstat

Gamma mean and variance

Description

m = gamstat(a,b) returns the mean of the gamma distribution defined by the shape parameter a and scale parameter b.

[m,v] = gamstat(a,b) also returns the variance for the distribution.

example

Examples

collapse all

Compute the mean and variance of a gamma distribution with the shape parameter a and scale parameter b.

a = 3;
b = 4;
[mean,variance] = gamstat(a,b)
mean = 
12
variance = 
48

Input Arguments

collapse all

Shape parameter, specified as a positive scalar value or an array of positive scalar values. If both a and b are arrays, they must be the same size. If either a or b is a scalar, then gamstat expands the scalar argument into a constant array of the same size as the other argument.

Data Types: single | double

Scale parameter, specified as a positive scalar value or an array of positive scalar values. If both a and b are arrays, they must be the same size. If either a or b is a scalar, then gamstat expands the scalar argument into a constant array of the same size as the other argument.

Data Types: single | double

Output Arguments

collapse all

Mean for the gamma distribution, returned as a numeric scalar or an array of numeric scalars. m is the same size as a and b. Each element in m is the mean of the gamma distribution specified by the corresponding elements in a and b. If a(i) or b(i) is less than or equal to zero, then m(i) is NaN.

The mean of the gamma distribution with parameters a and b is ab.

Variance for the gamma distribution, returned as a numeric scalar or an array of numeric scalars. v is the same size as a and b. Each element in v is the variance of the gamma distribution specified by the corresponding elements in a and b. If a(i) or b(i) is less than or equal to zero, then v(i) is NaN.

The variance of the gamma distribution with parameters a and b is ab2.

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a