# How to find the Gaussian function given probability and boundary?

I intend to find the Gaussian function, where $$p$$ is the probability, area under its curve, within the boundary $$r_{min}=- r_0$$ and $$r_{max} = +r_0$$.

Consider the following Gaussian function:

$$f(r) = \frac{1}{\sigma \sqrt{2\pi}}e^{-\frac{1}{2}\frac{r^2}{\sigma^2}}$$

To solve this, I employed the ff:

$$p =\int_{r_{min}}^{r_{max}} \frac{1}{\sigma \sqrt{2\pi}}e^{-\frac{1}{2}\frac{r^2}{\sigma^2}}dr$$

But: $$\int e^{-\alpha r^2} dr = \frac{\sqrt{\pi}erf(\sqrt{\alpha}r)}{2\sqrt{\alpha}}$$

Then: $$p=erf(\sigma \sqrt{2}r_0)$$

So: $$\sigma=erf^{-1}(p)/(\sqrt{2}r_0)$$

Finally

$$f(r) = \frac{1}{erf^{-1}(p)/(\sqrt{2}r_0) \sqrt{2\pi}}e^{-\frac{1}{2}\frac{r^2}{(erf^{-1}(p)/(\sqrt{2}r_0))^2}}$$

The solution seems sound, but when I graphed it, I dont see that the area under the curve within $$r_0$$ is actually $$p$$.

Below are the relevant images of what I am talking about.

The top image is the Gaussian graph I obtained while the bottom image is what I am expecting. The red line is where $$r_0$$ is.

The plot shown was only half of the curve, so I am expecting to get $$p/2$$ of the area

• You made two mistakes: (1) scaling between Erf and Normal density (2) algebra when inverting Erf (division done wrong). – Lee David Chung Lin Feb 14 at 14:14
• I corrected the algebra, its just typo. About the scaling? What would be the correct way for that? I am not that familiar with scaling in erf and normal density – Jones G Feb 14 at 14:23

The definition of the error function is $$\mathrm{Erf}(x) = \int\limits_{t = -x}^{t=x} \frac1{\sqrt\pi}e^{-t^2} \,dt$$
With that in mind, we have \begin{align} p &= \int\limits_{r = -r_0}^{r=r_0} \frac{1}{\sigma \sqrt{2\pi}}e^{-\frac{1}{2}\frac{r^2}{\sigma^2}}\,dr \qquad \text{, let}~~ t = \frac{r}{\sigma \sqrt 2} \\ &= \int\limits_{r = -r_0}^{r=r_0} \frac1{\sqrt\pi} e^{-( \frac{r}{\sigma \sqrt 2})^2 } \frac{dr}{\sigma \sqrt 2} \\ &= \int\limits_{t = -t_0}^{t=t_0} \frac1{\sqrt\pi}e^{-t^2} \,dt \qquad \text{, note that}~~ t_0 = \frac{r_0}{\sigma \sqrt 2} \\ &= \mathrm{Erf}\Bigl( \frac{r_0}{\sigma \sqrt 2} \Bigr) \end{align} $$\implies \mathrm{Erf}^{-1}(p) = \frac{r_0}{\sigma \sqrt 2} \qquad \implies \sigma = \frac{r_0}{\sqrt 2 \mathrm{Erf}^{-1}(p)}$$ Then you can proceed to carry out your further plans.