Beta parameter estimates with method of moments
parmhat = distfun_betafitmm( data )
a matrix of doubles, the data, in the interval [0,1].
a 1-by-2 matrix of doubles, the parameters of the Beta distribution. parmhat(1) is a, parmhat(2) is b.
Estimates the parameters of the Beta distribution with method of moments. In other words, finds the parameters so that the mean and variance of the distribution are equal to the empirical mean and empirical variance of the data.
The implementation is based on direct inversion of the moments.
On output, we have a>=0 and b>=0. If the exact a or b is lower than zero, the estimate is set to zero. If required, a or b is set to zero. In this case, the moments are not matched anymore.
// Samples from Beta distribution with // a=12 and b=42 data = [ 0.2876148 0.3311889 0.2448739 0.1452694 0.1861828 0.2299041 0.1619109 0.3711106 0.2198700 0.2831889 ] parmhat = distfun_betafitmm(data) a=parmhat(1); b=parmhat(2); // Compare the (mean,variance) of the // distribution against the data : // must be equal. [M,V]=distfun_betastat(a,b) M_data=mean(data) V_data=variance(data) // Error : variance is zero // parmhat = distfun_betafitmm([1 1]) | ![]() | ![]() |