We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b9104ae commit 1e0ca92Copy full SHA for 1e0ca92
1 file changed
src/Numerics/Distributions/Beta.cs
@@ -392,9 +392,13 @@ public IEnumerable<double> Samples()
392
/// <returns>a random number from the Beta distribution.</returns>
393
internal static double SampleUnchecked(System.Random rnd, double a, double b)
394
{
395
- var x = Gamma.SampleUnchecked(rnd, a, 1.0);
396
- var y = Gamma.SampleUnchecked(rnd, b, 1.0);
397
- return x == 0 ? 0 : x / (x + y);
+ double x, y;
+ do
+ {
398
+ x = Gamma.SampleUnchecked(rnd, a, 1.0);
399
+ y = Gamma.SampleUnchecked(rnd, b, 1.0);
400
+ } while (x == 0 && y == 0);
401
+ return x / (x + y);
402
}
403
404
internal static void SamplesUnchecked(System.Random rnd, double[] values, double a, double b)
0 commit comments