<s>[INST] Finding standard deviation given mean and probability of a sample (algebraically). I am trying to solve for the standard deviation of a normal distribution given the probability of a sample and mean:
$P(x)=\frac{1}{\sigma\sqrt{2\pi}}\exp(-0.5(\frac{x-\mu}{\sigma})^2)$
So given $P(x)=a, x=b, \mu=c$ is it possible to find a closed-form solution of $\sigma$?
I tried reducing the problem to a form where it could be solved using the Lambert W function with no luck.
 [/INST] $\require{begingroup} \begingroup$
$\def\e{\mathrm{e}}\def\W{\operatorname{W}}\def\Wp{\operatorname{W_0}}\def\Wm{\operatorname{W_{-1}}}\def\Catalan{\mathsf{Catalan}}$
Indeed, this case is suitable for solution in terms of the Lambert $\W$ function as follows:
\begin{align} 
\frac1{\sqrt{2\pi}\sigma}\exp\left(-\frac{(b-c)^2}{2\sigma^2}\right)
&=a
\\
\frac1{2\pi\sigma^2}\exp\left(-\frac{(b-c)^2}{\sigma^2}\right)
&=a^2
\\
\frac1{\sigma^2}\exp\left(-\frac{(b-c)^2}{\sigma^2}\right)
&=2\pi a^2
\\
\frac{-(b-c)^2}{\sigma^2}\exp\left(-\frac{(b-c)^2}{\sigma^2}\right)
&=-2\pi(b-c)^2 a^2
\\
\W\left(\frac{-(b-c)^2}{\sigma^2}\exp\left(-\frac{(b-c)^2}{\sigma^2}\right)\right)
&=\W\left(-2\pi(b-c)^2 a^2\right)
\\
\frac{-(b-c)^2}{\sigma^2}
&=\W\left(-2\pi(b-c)^2 a^2\right)
\\
\sigma^2&=
\frac{(b-c)^2}{-\W\left(-2\pi(b-c)^2 a^2\right)}
\\
\sigma&=
\frac{|b-c|}{\sqrt{-\W\left(-2\pi(b-c)^2 a^2\right)}}
.
\end{align}
Or, using identity $\W(x)=x\exp(-\W(x))$, we can get
an equivalent, but more convenient form that includes the case $b=c$
without resort to the limits,
\begin{align}
\sigma&=
\frac1{a\sqrt{2\pi}}\,\exp\left(\tfrac12\,\W\left(-2\pi a^2(b-c)^2\right)\right)
.
\end{align}
Note that if $(-2\pi a^2(b-c)^2)\in(-\tfrac1{\e},0)$ there are two real solutions for $\sigma$:
\begin{align}
\sigma_0&=
\frac1{a\sqrt{2\pi}}\,\exp\left(\tfrac12\,\Wp\left(-2\pi a^2(b-c)^2\right)\right)
\\
\text{and }\quad
\sigma_1&=
\frac1{a\sqrt{2\pi}}\,\exp\left(\tfrac12\,\Wm\left(-2\pi a^2(b-c)^2\right)\right)
,
\end{align}
where $\Wp$ and $\Wm$ are the two real branches of the Lambert $\W$ function.
For example, setting $a=0.75,\ \mu=0.5$, $x=0.2$ (or $x=0.8$)
corresponds to two curves, one with
$\sigma=\sigma_0\approx0.403437$
and another
with $\sigma=\sigma_1\approx0.234237$, see image below:

$\endgroup$
</s>