MATLAB: Define beta distribution function

beta distributionMATLAB

how to define N=100000 random variables in beta distribution with (an=0, bn=1) mu(mean)=0.37 sigma(standard deviation)=0.07

Best Answer

You cannot independently choose the a, b parameters, and mu, sigma. You can only choose one pair at a time. Also, parameter an=0 and bn=1 only generate constant zero, so I suppose you wrote that by mistake. The following shows how to generate random beta numbers with mean=0.37 and std=0.07. It uses formula from this line: https://en.wikipedia.org/wiki/Beta_distribution#Mean_and_variance
mu = 0.37;
std = 0.07;
var = std.^2;
v = mu*(1-mu)/var-1;
a = mu*v;
b = (1-mu)*v;
N = 100000;
r = betarnd(a, b, N, 1);