# Creating a Weibull probability density

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.

• Just remove the empty lines after \begin{equation} and before \end{equation}.
– user121799
Mar 9 '18 at 16:36
• Welcome to TeX.Stackexchange! Mar 9 '18 at 16:36
• Thank you! That has indeed solved it, I didn't know the \equation{} environment was so sensitive to empty lines. Mar 9 '18 at 16:49
• Empty lines in (La)TeX denote the end of a paragraph. Mar 9 '18 at 16:57

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. \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}

• Upvote your answer. But I'm curious to understand the difference between cases and dcases. Mar 10 '18 at 9:02
• @Sebastiano - Thanks! The main difference between the two environments is that dcases typesets its contents in \displaystyle math mode.
– Mico
Mar 10 '18 at 9:39