I'm trying to learn about the Gaussian Normal distribution using Mathematica.

So I defined my Gaussian like this

Gaus[x_, mu_, sigma_] = 1/(sigma*Sqrt[2 \[Pi]]) E^(-(1/2) ((x - mu)/sigma)^2);

I just tried to integrate it

Integrate[Gaus[x, mu, sigma], x, Assumptions -> {sigma > 0}]

which gives me

-(1/2) Erf[(mu - x)/(Sqrt[2] sigma)]

I plot it using a manipulate block

   Style["Gaussian Normal", Bold],
   Plot[Gaus[x, mu, sigma], {x, -5, 5}, ImageSize -> Large, 
   PlotRange -> Full],
   Style["Gaussian Integral", Bold],
   Plot[-(1/2) Erf[(mu - x)/(Sqrt[2] sigma)], {x, -5, 5}, 
   ImageSize -> Large, PlotRange -> Full]
 {mu, -5, 5, 1}, {sigma, 0.5, 2, 0.5}]

This is what I get for mean=1 and stdev=1:

Gaussian and Error function plot

I don't understand why the erf function is going through (0/0) and is not shifted up by 1/2.

  • $\begingroup$ The correct integral is just CDF[NormalDistribution[mu, sigma], x] $\endgroup$ – Bob Hanlon Jun 22 '20 at 15:59

The antiderivative Integrate isn't unique.


Integrate[Gaus[x, mu, sigma], {x, -Infinity, x},Assumptions -> {sigma > 0}]
(*1/2 (1 + Erf[(-mu + x)/(Sqrt[2] sigma)])*)

to get the expected result!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.