Main Content

betastat

Beta mean and variance

Syntax

[M,V] = betastat(A,B)

Description

[M,V] = betastat(A,B), withA>0andB>0, returns the mean of and variance for the beta distribution with parameters specified byAandB.AandBcan be vectors, matrices, or multidimensional arrays that have the same size, which is also the size ofMandV. A scalar input forAorBis expanded to a constant array with the same dimensions as the other input.

The mean of the beta distribution with parametersaandbis a / ( a + b ) and the variance is

a b ( a + b + 1 ) ( a + b ) 2

Examples

If parametersaandbare equal, the mean is 1/2.

a = 1:6; [m,v] = betastat(a,a) m = 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 v = 0.0833 0.0500 0.0357 0.0278 0.0227 0.0192

Extended Capabilities

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

Introduced before R2006a