private double beta double double Random rand double p1 p2 result do p

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
private double beta(double m, double v, Random rand)
{
double p1, p2,result=0;
do
{
p1 = rand.NextDouble();
p2 = rand.NextDouble();
} while (Math.Pow(p1, 1/m) + Math.Pow(p2, 1/v) >= 1);
result = Math.Pow(p1, 1 / m) / (Math.Pow(p1, 1 / m) + Math.Pow(p2, 1 / v));
return result;
}