From 8cc4c3c1e92837d475f28304da35b54f0934f799 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sat, 26 Sep 2020 23:25:28 +0200 Subject: [PATCH] Fixed cauchy-lorentz function --- FastRng/Double/Distributions/CauchyLorentz.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FastRng/Double/Distributions/CauchyLorentz.cs b/FastRng/Double/Distributions/CauchyLorentz.cs index 96d0c04..936d6f0 100644 --- a/FastRng/Double/Distributions/CauchyLorentz.cs +++ b/FastRng/Double/Distributions/CauchyLorentz.cs @@ -27,10 +27,10 @@ namespace FastRng.Double.Distributions public async ValueTask GetDistributedValue(CancellationToken token = default) { if (this.Random == null) - return System.Double.NaN; + return double.NaN; var value = await this.Random.GetUniform(token); - return this.Median + scale * Math.Tan(Math.PI * (value - 0.5)); + return 1.0 / (Math.PI * this.Scale * (1 + Math.Pow((value - this.Median) / this.Scale, 2))); } } } \ No newline at end of file