From 4369ee09cf166a0cd15abff906ca9fc4e53fe537 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Sat, 7 Nov 2015 10:41:08 +0100 Subject: [PATCH] Distributions: Normal.CDF to use same Erfc implementation as the instance method, avoiding a problematic subtraction (accuracy) #348 --- src/Numerics/Distributions/Normal.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Numerics/Distributions/Normal.cs b/src/Numerics/Distributions/Normal.cs index b3a028e2..2ee18d72 100644 --- a/src/Numerics/Distributions/Normal.cs +++ b/src/Numerics/Distributions/Normal.cs @@ -4,7 +4,7 @@ // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com // -// Copyright (c) 2009-2013 Math.NET +// Copyright (c) 2009-2015 Math.NET // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation @@ -496,7 +496,7 @@ namespace MathNet.Numerics.Distributions throw new ArgumentException(Resources.InvalidDistributionParameters); } - return 0.5*(1.0 + SpecialFunctions.Erf((x - mean)/(stddev*Constants.Sqrt2))); + return 0.5*SpecialFunctions.Erfc((mean - x)/(stddev*Constants.Sqrt2)); } ///