Renamed normal distribution

This commit is contained in:
Thorsten Sommer 2020-10-31 19:44:18 +01:00
parent a710226941
commit 3bf829d684
3 changed files with 13 additions and 13 deletions

View File

@ -5,7 +5,7 @@ using System.Threading.Tasks;
namespace FastRng.Double.Distributions namespace FastRng.Double.Distributions
{ {
public sealed class Normal : IDistribution public sealed class NormalS02M05 : IDistribution
{ {
private const double SQRT_2_PI = 2.506628275; private const double SQRT_2_PI = 2.506628275;
private const double STDDEV = 0.2; private const double STDDEV = 0.2;
@ -14,7 +14,7 @@ namespace FastRng.Double.Distributions
private ShapeFitter fitter; private ShapeFitter fitter;
private IRandom random; private IRandom random;
public Normal() public NormalS02M05()
{ {
} }
@ -24,7 +24,7 @@ namespace FastRng.Double.Distributions
set set
{ {
this.random = value; this.random = value;
this.fitter = new ShapeFitter(Normal.ShapeFunction, this.random, 100); this.fitter = new ShapeFitter(NormalS02M05.ShapeFunction, this.random, 100);
} }
} }

View File

@ -8,7 +8,7 @@ using NUnit.Framework;
namespace FastRngTests.Double.Distributions namespace FastRngTests.Double.Distributions
{ {
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
public class Normal public class NormalS02M05
{ {
[Test] [Test]
[Category(TestCategories.COVER)] [Category(TestCategories.COVER)]
@ -18,7 +18,7 @@ namespace FastRngTests.Double.Distributions
const double MEAN = 0.5; const double MEAN = 0.5;
const double STANDARD_DEVIATION = 0.2; const double STANDARD_DEVIATION = 0.2;
var dist = new FastRng.Double.Distributions.Normal(); var dist = new FastRng.Double.Distributions.NormalS02M05();
var stats = new RunningStatistics(); var stats = new RunningStatistics();
var fra = new FrequencyAnalysis(); var fra = new FrequencyAnalysis();
var rng = new MultiThreadedRng(); var rng = new MultiThreadedRng();
@ -47,7 +47,7 @@ namespace FastRngTests.Double.Distributions
{ {
var rng = new MultiThreadedRng(); var rng = new MultiThreadedRng();
var samples = new double[1_000]; var samples = new double[1_000];
var dist = new FastRng.Double.Distributions.Normal(); var dist = new FastRng.Double.Distributions.NormalS02M05();
for (var n = 0; n < samples.Length; n++) for (var n = 0; n < samples.Length; n++)
samples[n] = await rng.NextNumber(-1.0, 1.0, dist); samples[n] = await rng.NextNumber(-1.0, 1.0, dist);
@ -63,7 +63,7 @@ namespace FastRngTests.Double.Distributions
{ {
var rng = new MultiThreadedRng(); var rng = new MultiThreadedRng();
var samples = new double[1_000]; var samples = new double[1_000];
var dist = new FastRng.Double.Distributions.Normal(); var dist = new FastRng.Double.Distributions.NormalS02M05();
for (var n = 0; n < samples.Length; n++) for (var n = 0; n < samples.Length; n++)
samples[n] = await rng.NextNumber(0.0, 1.0, dist); samples[n] = await rng.NextNumber(0.0, 1.0, dist);
@ -78,7 +78,7 @@ namespace FastRngTests.Double.Distributions
public async Task TestNormalGeneratorWithRange03() public async Task TestNormalGeneratorWithRange03()
{ {
var rng = new MultiThreadedRng(); var rng = new MultiThreadedRng();
var dist = new FastRng.Double.Distributions.Normal { Random = rng }; // Test default parameters var dist = new FastRng.Double.Distributions.NormalS02M05 { Random = rng }; // Test default parameters
var samples = new double[1_000]; var samples = new double[1_000];
for (var n = 0; n < samples.Length; n++) for (var n = 0; n < samples.Length; n++)
@ -94,7 +94,7 @@ namespace FastRngTests.Double.Distributions
[Category(TestCategories.NORMAL)] [Category(TestCategories.NORMAL)]
public async Task NoRandomNumberGenerator01() public async Task NoRandomNumberGenerator01()
{ {
var dist = new FastRng.Double.Distributions.Normal(); var dist = new FastRng.Double.Distributions.NormalS02M05();
Assert.DoesNotThrowAsync(async () => await dist.GetDistributedValue()); Assert.DoesNotThrowAsync(async () => await dist.GetDistributedValue());
Assert.That(await dist.GetDistributedValue(), Is.NaN); Assert.That(await dist.GetDistributedValue(), Is.NaN);
} }

View File

@ -170,19 +170,19 @@ namespace FastRngTests.Double
Assert.That(wasCanceled, Is.True, "The consumer was not canceled"); Assert.That(wasCanceled, Is.True, "The consumer was not canceled");
var tokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(3)); var tokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(3));
await rng.NextNumber(new Normal(), tokenSource2.Token); await rng.NextNumber(new NormalS02M05(), tokenSource2.Token);
Assert.That(tokenSource2.IsCancellationRequested, Is.True); Assert.That(tokenSource2.IsCancellationRequested, Is.True);
tokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(3)); tokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(3));
await rng.NextNumber(-1d, 1d, new Normal(), tokenSource2.Token); await rng.NextNumber(-1d, 1d, new NormalS02M05(), tokenSource2.Token);
Assert.That(tokenSource2.IsCancellationRequested, Is.True); Assert.That(tokenSource2.IsCancellationRequested, Is.True);
tokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(3)); tokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(3));
await rng.NextNumber(0u, 6u, new Normal(), tokenSource2.Token); await rng.NextNumber(0u, 6u, new NormalS02M05(), tokenSource2.Token);
Assert.That(tokenSource2.IsCancellationRequested, Is.True); Assert.That(tokenSource2.IsCancellationRequested, Is.True);
tokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(3)); tokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(3));
await rng.NextNumber(0ul, 6ul, new Normal(), tokenSource2.Token); await rng.NextNumber(0ul, 6ul, new NormalS02M05(), tokenSource2.Token);
Assert.That(tokenSource2.IsCancellationRequested, Is.True); Assert.That(tokenSource2.IsCancellationRequested, Is.True);
} }