Added float implementations
This commit is contained in:
parent
1651fbaa2b
commit
d4e4e2c1c9
13
FastRng/Float/Distributions/CauchyLorentzX0.cs
Normal file
13
FastRng/Float/Distributions/CauchyLorentzX0.cs
Normal file
@ -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)));
|
||||||
|
}
|
||||||
|
}
|
13
FastRng/Float/Distributions/CauchyLorentzX1.cs
Normal file
13
FastRng/Float/Distributions/CauchyLorentzX1.cs
Normal file
@ -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)));
|
||||||
|
}
|
||||||
|
}
|
23
FastRng/Float/Distributions/ChiSquareK1.cs
Normal file
23
FastRng/Float/Distributions/ChiSquareK1.cs
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
23
FastRng/Float/Distributions/ChiSquareK10.cs
Normal file
23
FastRng/Float/Distributions/ChiSquareK10.cs
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
23
FastRng/Float/Distributions/ChiSquareK4.cs
Normal file
23
FastRng/Float/Distributions/ChiSquareK4.cs
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user