Code: Select all
You can't use '\prevdepth' in restricted horizontal mode.
\no interlineskp -> \prevdepth
$
, which I don't understand because I think I've put things in the proper environments.Hopefully this is adequate as a MWE.
Code: Select all
\documentclass[letterpaper]{article}
\usepackage{amsmath}
\usepackage{algorithm2e}
\begin{document}
The Laplace distribution has the CDF
\begin{equation*}F_x(x)=
\begin{cases}
\frac{\theta}{2}exp(\frac{x-\mu}{b}) & \text{if } x \leq \mu \\
1-\frac{\theta}{2}exp(\frac{x-\mu}{b}) & \text{if } x > \mu
\end{cases}
\end{equation*}
We can use the following algorithm to generate observations from the Laplace distribution using U~(0,1)
\begin{algorithm}
\SetAlgoLined
\KwData[U~(0, 1)}
\KwResult{Generate observations from the Laplace distribution}
initialization\;
\For{U~(0, 1)}{
\eIf{u < 0.5}{
\begin{equation*}
x={ln(\frac{2u}{\theta}}{\theta}
\end{equation*}
}
\eIf{u $\geq$ 0.5}{
\begin{equation*}
x=-\theta ln(\frac{2-2u}{\theta})
\end{equation*}
}
}
\caption{How to generate Laplace variables from U~(0, 1)}
\end{algorithm}
\end{document}