[Tex/LaTex] Creating a Weibull probability density

equationsmath-mode

I want to include a probability density of a Weibull distribution as a part of my document as an equation. Essentially the same basic density on the wikipedia page of Weibull distributions (https://en.wikipedia.org/wiki/Weibull_distribution). This is my attempt to code the equation I want.

\begin{equation}

f_X(x; \lambda, k) = \left\{ \begin{array}{cl}
    \frac{k}{\lambda}(\frac{x}{k})^{k-1} e^{-(x/\lambda)^k} & \ ; \ x \geq 0 \\
    0 & \ ; \ x < 0 \end{array} \right. \


\end{equation}

This generates the correct form of equation, but I get a missing $ inserted error from this code. I read up on the error and think that some of the symbols I'm using inside the mathmode of \equation may not be appropriate although I'm not sure how to find out.

Best Answer

In addition to getting rid of the blank lines inside the equation environment to take care of the immediate problem, you may want to enhance the overall look of the equation, mainly by replacing the generic array environment with the specialized dcases environment, which was designed for cases (pun intended) such as yours.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for 'dcases' env.
\begin{document} 
\begin{equation}
f_X(x; \lambda, k) = 
\begin{dcases}
\frac{k}{\lambda}\Bigl(\frac{x}{k}\Bigr)^{k-1} \exp\bigl(-(x/\lambda)^k\bigr) & x \geq 0 \\[1ex]
0 & x < 0 
\end{dcases}
\end{equation}
\end{document}
Related Question