Renamed GetUniform

This commit is contained in:
tsommer committed 2020-09-26 11:34:26 +02:00
1 parent 9eda579197
commit 7b93748c0b
6 files changed
+9 -9

No files matched your search

+2 -2
View File
@@ -28,9 +28,9 @@ namespace FastRng.Distributions
return 0;
if(this.Mean == 1)
return -Math.Log(await this.Random.GetUniformDouble(token));
return -Math.Log(await this.Random.GetUniform(token));
else
return this.Mean * -Math.Log(await this.Random.GetUniformDouble(token));
return this.Mean * -Math.Log(await this.Random.GetUniform(token));
}
}
}
+2 -2
View File
@@ -49,7 +49,7 @@ namespace FastRng.Distributions
while (v <= 0.0);
v = v * v * v;
var u = await this.Random.GetUniformDouble(token);
var u = await this.Random.GetUniform(token);
var xSquared = x * x;
if (u < 1.0 - 0.0331 * xSquared * xSquared || Math.Log(u) < 0.5 * xSquared + d * (1.0 - v + Math.Log(v)))
@@ -61,7 +61,7 @@ namespace FastRng.Distributions
var dist = new Gamma{ Scale = 1, Shape = 1 + this.Shape};
var g = await this.Random.NextNumber(0.0f, 1.0f, dist, token); // TODO: Use double
var w = await this.Random.GetUniformDouble(token);
var w = await this.Random.GetUniform(token);
return this.Scale * g * Math.Pow(w, 1.0 / this.Shape);
}
}
+2 -2
View File
@@ -29,8 +29,8 @@ namespace FastRng.Distributions
if (this.Random == null)
return 0;
var u1 = await this.Random.GetUniformDouble(token);
var u2 = await this.Random.GetUniformDouble(token);
var u1 = await this.Random.GetUniform(token);
var u2 = await this.Random.GetUniform(token);
var r = Math.Sqrt(-2.0 * Math.Log(u1));
var theta = 2.0 * Math.PI * u2;
var value = r * Math.Sin(theta);
+1 -1
View File
@@ -7,6 +7,6 @@ namespace FastRng.Distributions
{
public IRandom Random { get; set; }
public async Task<double> GetDistributedValue(CancellationToken token = default) => this.Random == null ? 0 : await this.Random.GetUniformDouble(token);
public async Task<double> GetDistributedValue(CancellationToken token = default) => this.Random == null ? 0 : await this.Random.GetUniform(token);
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ namespace FastRng
{
public interface IRandom
{
public Task<double> GetUniformDouble(CancellationToken cancel = default);
public Task<double> GetUniform(CancellationToken cancel = default);
public Task<uint> NextNumber(uint rangeStart, uint rangeEnd, IDistribution distribution, CancellationToken cancel = default);
+1 -1
View File
@@ -133,7 +133,7 @@ namespace FastRng
#region Implementing interface
public async Task<double> GetUniformDouble(CancellationToken cancel = default) => await this.channelRandomUniformDistributedDouble.Reader.ReadAsync(cancel);
public async Task<double> GetUniform(CancellationToken cancel = default) => await this.channelRandomUniformDistributedDouble.Reader.ReadAsync(cancel);
public async Task<uint> NextNumber(uint rangeStart, uint rangeEnd, IDistribution distribution, CancellationToken cancel = default)
{