This commit is contained in:
Thorsten Sommer 2020-09-26 11:57:26 +02:00
parent 43df57b1a1
commit 14ea7dac4a

View File

@ -0,0 +1,20 @@
using System.Threading;
using System.Threading.Tasks;
namespace FastRng.Double.Distributions
{
public sealed class ChiSquare : IDistribution
{
public IRandom Random { get; set; }
public double DegreesOfFreedom { get; set; } = 1.0;
public async ValueTask<double> GetDistributedValue(CancellationToken token)
{
if (this.Random == null)
return 0.0;
return await this.Random.NextNumber(new Gamma{ Shape = 0.5 * this.DegreesOfFreedom, Scale = 2.0 }, token);
}
}
}