title: c# NormalDistribution implementation
body: <p>I need the C# implementation(source code) of a <code>NormalDistribution</code> function in <code>System.Web.DataVisualization.dll</code>, I tried source using the already available functions from github to calculate NORM.S.DIST but they are not accurate and not matching with excel values.</p>
  
  <p>Below is the code I used and it gives me 1.2664557440189636E-43 (almost zero) for an input of 13.803404798240017. On the other hand excel and the <code>NormalDistribution</code> function in <code>DataVisualization</code> retruns 1 as the result.</p>
  
  <pre><code>public static double NS(double zValue)
  {
      const double b1 = 0.319381530;
      const double b2 = -0.356563782;
      const double b3 = 1.781477937;
      const double b4 = -1.821255978;
      const double b5 = 1.330274429;
      const double p = 0.2316419;
      const double c = 0.39894228;
  
      if (zValue &gt;= 0.0)
      {
          double t = 1.0 / (1.0 + p * zValue);
          return (1.0 - c * Math.Exp(-zValue * zValue / 2.0) * t * (t * (t * (t * (t * b5 + b4) + b3) + b2) + b1));
       }
       else
       {
           double t = 1.0 / (1.0 - p * zValue);
           return (c * Math.Exp(-zValue * zValue / 2.0) * t * (t * (t * (t * (t * b5 + b4) + b3) + b2) + b1));
        }
  }
  </code></pre>
  
  <p>I tried <code>ILSpy</code> to see the code in <code>DataVisualization.dll</code> but no luck, please suggest how to we get that source code(if possible), I thought MS has open sourced their .Net code base but it's not true for all assemblies. or is there any better way to calculate NORM.S.DIST with good accuracy? </p>
  
  <p>Thanks!!</p>