This question is linked to the normal distribution for a random variable. The probability density function (pdf) is expressed as:
\begin{equation} \frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{(x - \mu)^2}{2 \sigma^2}} \end{equation}
and the cumulative distribution function (cdf) is expressed as:
\begin{equation} \frac12\left[1 + \operatorname{erf}\left( \frac{x-\mu}{\sigma\sqrt{2}}\right)\right] \end{equation}
pdf or cdf functions might take extremely low values. When computing logarithm of pdf,
\begin{equation} - \operatorname{log}(\sigma\sqrt{2\pi}) - \frac{(x - \mu)^2}{2 \sigma^2} \end{equation}
is used directly, instead of first computing eq. 1, then taking the log.
Currently I compute the log of the cdf by first computing eq. 2, then taking its log. This creates numerical underflows in my program. I would like to compute the log directly, using a formula similar to eq. 3.
Is it possible ?