Optimization

This commit is contained in:
Thorsten Sommer 2020-09-26 11:49:50 +02:00
parent 45e8596588
commit b1dfeaec20
4 changed files with 4 additions and 4 deletions

View File

@ -25,7 +25,7 @@ namespace FastRng.Double.Distributions
public async ValueTask<double> GetDistributedValue(CancellationToken token)
{
if (this.Random == null)
return 0;
return 0.0;
if(this.Mean == 1)
return -Math.Log(await this.Random.GetUniform(token));

View File

@ -27,7 +27,7 @@ namespace FastRng.Double.Distributions
public async ValueTask<double> GetDistributedValue(CancellationToken token)
{
if (this.Random == null)
return 0;
return 0.0;
// Implementation based on "A Simple Method for Generating Gamma Variables"
// by George Marsaglia and Wai Wan Tsang. ACM Transactions on Mathematical Software

View File

@ -27,7 +27,7 @@ namespace FastRng.Double.Distributions
public async ValueTask<double> GetDistributedValue(CancellationToken token = default)
{
if (this.Random == null)
return 0;
return 0.0;
var u1 = await this.Random.GetUniform(token);
var u2 = await this.Random.GetUniform(token);

View File

@ -7,6 +7,6 @@ namespace FastRng.Double.Distributions
{
public IRandom Random { get; set; }
public async ValueTask<double> GetDistributedValue(CancellationToken token = default) => this.Random == null ? 0 : await this.Random.GetUniform(token);
public async ValueTask<double> GetDistributedValue(CancellationToken token = default) => this.Random == null ? 0.0 : await this.Random.GetUniform(token);
}
}