diff --git a/FastRng/Double/Distributions/ChiSquare.cs b/FastRng/Double/Distributions/ChiSquare.cs new file mode 100644 index 0000000..2a6b568 --- /dev/null +++ b/FastRng/Double/Distributions/ChiSquare.cs @@ -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 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); + } + } +} \ No newline at end of file