Use standard formula with updated parameters
This commit is contained in:
parent
329057198d
commit
7b5727802f
@ -8,7 +8,7 @@ namespace FastRng.Double.Distributions
|
|||||||
public sealed class Normal : IDistribution
|
public sealed class Normal : IDistribution
|
||||||
{
|
{
|
||||||
private const double SQRT_2PI = 2.506628275;
|
private const double SQRT_2PI = 2.506628275;
|
||||||
private const double STDDEV = 0.4;
|
private const double STDDEV = 0.2;
|
||||||
private const double MEAN = 0.5;
|
private const double MEAN = 0.5;
|
||||||
|
|
||||||
private ShapeFitter fitter;
|
private ShapeFitter fitter;
|
||||||
@ -24,11 +24,11 @@ namespace FastRng.Double.Distributions
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.random = value;
|
this.random = value;
|
||||||
this.fitter = new ShapeFitter(Normal.ShapeFunction, this.random, 50, 0.99);
|
this.fitter = new ShapeFitter(Normal.ShapeFunction, this.random, 50, 1.93);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double ShapeFunction(double x) => 1.0 / (STDDEV * SQRT_2PI) * Math.Exp(-Math.Pow((x - MEAN) / STDDEV, 2.0));
|
private static double ShapeFunction(double x) => 1.0 / (STDDEV * SQRT_2PI) * Math.Exp(-0.5 * Math.Pow((x - MEAN) / STDDEV, 2.0));
|
||||||
|
|
||||||
public async ValueTask<double> GetDistributedValue(CancellationToken token = default)
|
public async ValueTask<double> GetDistributedValue(CancellationToken token = default)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user