OK, my bad. The error is in the last equation:

\begin{align}
KL(p, q) &amp;= - \int p(x) \log q(x) dx + \int p(x) \log p(x) dx\\
&amp;=\frac{1}{2} \log (2 \pi \sigma_2^2) + \frac{\sigma_1^2 + (\mu_1 - \mu_2)^2}{2 \sigma_2^2} - \frac{1}{2} (1 + \log 2 \pi \sigma_1^2)\\
&amp;= \log \frac{\sigma_2}{\sigma_1} + \frac{\sigma_1^2 + (\mu_1 - \mu_2)^2}{2 \sigma_2^2}
\end{align}

$-\frac{1}{2}$ is missing in the last line. With it the last line becomes zero when $\mu_1=\mu_2$ and $\sigma_1=\sigma_2$.

KL divergence between two univariate Gaussians
I have a common script which Im including in my PHPcron files and the files which are accessing through the browser. Some part of the code, I need only for non cron files. How can I detect whether the execution is from CLI or through browser (I know it can be done by passing some arguments with the cron files but I dont have access to crontab). Is there any other way ?
