From 14ea7dac4a234b52caba2c71117d9c5027cacb2c Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sat, 26 Sep 2020 11:57:26 +0200 Subject: [PATCH] Initial --- FastRng/Double/Distributions/ChiSquare.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 FastRng/Double/Distributions/ChiSquare.cs 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