diff --git a/FastRng/Float/Distributions/CauchyLorentzX0.cs b/FastRng/Float/Distributions/CauchyLorentzX0.cs new file mode 100644 index 0000000..3875d1d --- /dev/null +++ b/FastRng/Float/Distributions/CauchyLorentzX0.cs @@ -0,0 +1,13 @@ +using System; + +namespace FastRng.Float.Distributions +{ + public sealed class CauchyLorentzX0 : Distribution + { + private const float CONSTANT = 0.31f; + private const float SCALE = 0.1f; + private const float MEDIAN = 0.0f; + + protected override float ShapeFunction(float x) => CONSTANT * (1.0f / (MathF.PI * SCALE)) * ((SCALE * SCALE) / (MathF.Pow(x - MEDIAN, 2f) + (SCALE * SCALE))); + } +} \ No newline at end of file diff --git a/FastRng/Float/Distributions/CauchyLorentzX1.cs b/FastRng/Float/Distributions/CauchyLorentzX1.cs new file mode 100644 index 0000000..633001e --- /dev/null +++ b/FastRng/Float/Distributions/CauchyLorentzX1.cs @@ -0,0 +1,13 @@ +using System; + +namespace FastRng.Float.Distributions +{ + public sealed class CauchyLorentzX1 : Distribution + { + private const float CONSTANT = 0.31f; + private const float SCALE = 0.1f; + private const float MEDIAN = 1.0f; + + protected override float ShapeFunction(float x) => CONSTANT * (1.0f / (MathF.PI * SCALE)) * ((SCALE * SCALE) / (MathF.Pow(x - MEDIAN, 2f) + (SCALE * SCALE))); + } +} \ No newline at end of file diff --git a/FastRng/Float/Distributions/ChiSquareK1.cs b/FastRng/Float/Distributions/ChiSquareK1.cs new file mode 100644 index 0000000..c8c3fd5 --- /dev/null +++ b/FastRng/Float/Distributions/ChiSquareK1.cs @@ -0,0 +1,23 @@ +using System; + +namespace FastRng.Float.Distributions +{ + public sealed class ChiSquareK1 : Distribution + { + private const float K = 1.0f; + private const float K_HALF = K * 0.5f; + private const float K_HALF_MINUS_ONE = K_HALF - 1.0f; + private const float CONSTANT = 0.252f; + + private static readonly float DIVISOR; + + static ChiSquareK1() + { + var twoToTheKHalf = MathF.Pow(2f, K_HALF); + var gammaKHalf = MathTools.Gamma(K_HALF); + DIVISOR = twoToTheKHalf * gammaKHalf; + } + + protected override float ShapeFunction(float x) => CONSTANT * ((MathF.Pow(x, K_HALF_MINUS_ONE) * MathF.Exp(-x * 0.5f)) / DIVISOR); + } +} \ No newline at end of file diff --git a/FastRng/Float/Distributions/ChiSquareK10.cs b/FastRng/Float/Distributions/ChiSquareK10.cs new file mode 100644 index 0000000..8dbdd6e --- /dev/null +++ b/FastRng/Float/Distributions/ChiSquareK10.cs @@ -0,0 +1,23 @@ +using System; + +namespace FastRng.Float.Distributions +{ + public sealed class ChiSquareK10 : Distribution + { + private const float K = 10.0f; + private const float K_HALF = K * 0.5f; + private const float K_HALF_MINUS_ONE = K_HALF - 1.0f; + private const float CONSTANT = 0.252f; + + private static readonly float DIVISOR; + + static ChiSquareK10() + { + var twoToTheKHalf = MathF.Pow(2f, K_HALF); + var gammaKHalf = MathTools.Gamma(K_HALF); + DIVISOR = twoToTheKHalf * gammaKHalf; + } + + protected override float ShapeFunction(float x) => CONSTANT * ((MathF.Pow(x, K_HALF_MINUS_ONE) * MathF.Exp(-x * 0.5f)) / DIVISOR); + } +} \ No newline at end of file diff --git a/FastRng/Float/Distributions/ChiSquareK4.cs b/FastRng/Float/Distributions/ChiSquareK4.cs new file mode 100644 index 0000000..aa545f4 --- /dev/null +++ b/FastRng/Float/Distributions/ChiSquareK4.cs @@ -0,0 +1,23 @@ +using System; + +namespace FastRng.Float.Distributions +{ + public sealed class ChiSquareK4 : Distribution + { + private const float K = 4.0f; + private const float K_HALF = K * 0.5f; + private const float K_HALF_MINUS_ONE = K_HALF - 1.0f; + private const float CONSTANT = 0.252f; + + private static readonly float DIVISOR; + + static ChiSquareK4() + { + var twoToTheKHalf = MathF.Pow(2, K_HALF); + var gammaKHalf = MathTools.Gamma(K_HALF); + DIVISOR = twoToTheKHalf * gammaKHalf; + } + + protected override float ShapeFunction(float x) => CONSTANT * ((MathF.Pow(x, K_HALF_MINUS_ONE) * MathF.Exp(-x * 0.5f)) / DIVISOR); + } +} \ No newline at end of file