Added float implementations

This commit is contained in:
Thorsten Sommer 2020-10-31 23:55:45 +01:00
parent 1651fbaa2b
commit d4e4e2c1c9
5 changed files with 95 additions and 0 deletions

View 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)));
}
}

View 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)));
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}