I have been dabbling with the TikZ package to create some diagrams relevant to a first year microeconomics course. The following diagram of the probability density function (pdf) of a normal distribution may be useful to others wishing to integrate similar diagrams into their LaTeX documents or Beamer presentations. To use, insert the following code anywhere you like within a .tex document (you must include \usepackage{tikz}
in your header):
The Cumulative Density of
INSERT INTO .TEX DOCUMENT
\begin{tikzpicture} % define normal distribution function 'normaltwo' \def\normaltwo{\x,{4*1/exp(((\x-3)^2)/2)}} % input y parameter \def\y{4.4} % this line calculates f(y) \def\fy{4*1/exp(((\y-3)^2)/2)} % Shade orange area underneath curve. \fill [fill=orange!60] (2.6,0) -- plot[domain=0:4.4] (\normaltwo) -- ({\y},0) -- cycle; % Draw and label normal distribution function \draw[color=blue,domain=0:6] plot (\normaltwo) node[right] {}; % Add dashed line dropping down from normal. \draw[dashed] ({\y},{\fy}) -- ({\y},0) node[below] {$y$}; % Optional: Add axis labels \draw (-.2,2.5) node[left] {$f_Y(u)$}; \draw (3,-.5) node[below] {$u$}; % Optional: Add axes \draw[->] (0,0) -- (6.2,0) node[right] {}; \draw[->] (0,0) -- (0,5) node[above] {}; \end{tikzpicture}
The Probability of Falling Between and
INSERT INTO .TEX DOCUMENT
\begin{tikzpicture} % define normal distribution function 'normaltwo' \def\normaltwo{\x,{4*1/exp(((\x-3)^2)/2)}} % input x and y parameters \def\y{4.4} \def\x{3.4} % this line calculates f(y) \def\fy{4*1/exp(((\y-3)^2)/2)} \def\fx{4*1/exp(((\x-3)^2)/2)} % Shade orange area underneath curve. \fill [fill=orange!60] ({\x},0) -- plot[domain={\x}:{\y}] (\normaltwo) -- ({\y},0) -- cycle; % Draw and label normal distribution function \draw[color=blue,domain=0:6] plot (\normaltwo) node[right] {}; % Add dashed line dropping down from normal. \draw[dashed] ({\y},{\fy}) -- ({\y},0) node[below] {$y$}; \draw[dashed] ({\x},{\fx}) -- ({\x},0) node[below] {$x$}; % Optional: Add axis labels \draw (-.2,2.5) node[left] {$f_Y(u)$}; \draw (3,-.5) node[below] {$u$}; % Optional: Add axes \draw[->] (0,0) -- (6.2,0) node[right] {}; \draw[->] (0,0) -- (0,5) node[above] {}; \end{tikzpicture}
The TikZ code snippet above is meant to be dropped into a .tex document and work without any further “tinkering”. Please let me know if this is not the case!