2014-08-13 12:27:59 -04:00
|
|
|
\documentclass[varwidth=true, border=5pt]{article}
|
2014-08-11 13:54:04 -04:00
|
|
|
\usepackage[active,tightpage]{preview}
|
|
|
|
\usepackage[latin1]{inputenc}
|
|
|
|
\usepackage{amsmath}
|
|
|
|
\usepackage{pgfplots}
|
2014-08-23 13:58:32 -04:00
|
|
|
\pgfplotsset{compat=1.10}
|
2014-08-18 22:03:07 -04:00
|
|
|
\usepackage{tikz}
|
2015-10-14 14:25:34 +02:00
|
|
|
\usetikzlibrary{arrows,positioning}
|
2014-08-11 13:54:04 -04:00
|
|
|
\usepackage{helvet}
|
|
|
|
\usepackage[eulergreek]{sansmath}
|
|
|
|
|
|
|
|
\pgfmathdeclarefunction{gauss}{2}{%
|
|
|
|
\pgfmathparse{1/(sqrt(2*pi*#2))*exp(-((x-#1)^2)/(2*#2))}%
|
|
|
|
}
|
2014-08-20 17:56:58 -04:00
|
|
|
% to be used: \gauss(mean)(variance)
|
2014-08-11 13:54:04 -04:00
|
|
|
|
|
|
|
\pgfplotsset{
|
|
|
|
tick label style = {font=\sansmath\sffamily},
|
|
|
|
every axis label/.append style={font=\sffamily\footnotesize},
|
|
|
|
}
|
|
|
|
|
2014-08-20 17:56:58 -04:00
|
|
|
% Thanks to percusse for solving problems with the axis
|
|
|
|
|
2014-08-20 20:54:02 -04:00
|
|
|
\newcommand{\meanI}{80}
|
|
|
|
\newcommand{\meanII}{40}
|
|
|
|
\newcommand{\varI}{100}
|
|
|
|
\newcommand{\varII}{100}
|
|
|
|
|
|
|
|
\newcommand{\labelheight}{0.03}
|
|
|
|
|
|
|
|
\pgfmathsetmacro{\meanIheight}{1/(sqrt(2*pi*\varI))}%
|
|
|
|
\pgfmathsetmacro{\meanIIheight}{1/(sqrt(2*pi*\varII))}%
|
|
|
|
\pgfmathsetmacro{\plotheight}{max(\meanIheight, \meanIIheight, \labelheight+0.002)}%
|
|
|
|
|
2014-08-11 13:54:04 -04:00
|
|
|
\begin{document}
|
|
|
|
\begin{preview}
|
2014-08-13 12:27:59 -04:00
|
|
|
\tikzstyle{plotA}=[ultra thick,red!90!black]
|
|
|
|
\tikzstyle{plotB}=[ultra thick,cyan!50!black]
|
2014-08-11 13:54:04 -04:00
|
|
|
\begin{tikzpicture}
|
|
|
|
\begin{axis}[
|
|
|
|
width=13.5cm,
|
|
|
|
height=8.625cm,
|
|
|
|
% Grid
|
|
|
|
grid = major,
|
|
|
|
% size
|
|
|
|
xmin= 0, % start the diagram at this x-coordinate
|
2014-08-13 12:27:59 -04:00
|
|
|
xmax= 125, % end the diagram at this x-coordinate
|
2014-08-11 13:54:04 -04:00
|
|
|
ymin= 0, % start the diagram at this y-coordinate
|
|
|
|
ymax= 0.045, % end the diagram at this y-coordinate
|
|
|
|
% Legende
|
|
|
|
legend style={
|
|
|
|
font=\large\sansmath\sffamily,
|
|
|
|
at={(0.5,-0.18)},
|
|
|
|
anchor=north,
|
|
|
|
legend cell align=left,
|
|
|
|
legend columns=-1,
|
|
|
|
column sep=0.5cm
|
|
|
|
},
|
|
|
|
% Ticks
|
|
|
|
tick align=inside,
|
|
|
|
minor tick style={thick},
|
|
|
|
scaled y ticks = false,
|
2014-08-13 12:27:59 -04:00
|
|
|
xtick={40,70,80},
|
|
|
|
ytick=\empty,
|
2014-08-11 13:54:04 -04:00
|
|
|
% Axis
|
2014-08-20 17:56:58 -04:00
|
|
|
axis on top,
|
|
|
|
axis line style = {very thick,shorten <=-0.5\pgflinewidth},
|
2014-08-13 12:27:59 -04:00
|
|
|
axis lines = middle,
|
2014-08-11 13:54:04 -04:00
|
|
|
axis line style = very thick,
|
|
|
|
xlabel=$x$,
|
|
|
|
x label style={at={(axis description cs:0.5,0)},
|
|
|
|
anchor=north,
|
|
|
|
font=\boldmath\Large},
|
2014-08-13 12:27:59 -04:00
|
|
|
ylabel=$f(x)$,
|
|
|
|
y label style={at={(axis description cs:0,0.5)},
|
2014-08-11 13:54:04 -04:00
|
|
|
anchor=south,
|
2014-08-13 12:27:59 -04:00
|
|
|
rotate=90,
|
2014-08-11 13:54:04 -04:00
|
|
|
font=\boldmath\Large},
|
|
|
|
]
|
2014-08-18 22:03:07 -04:00
|
|
|
|
|
|
|
\coordinate (plotAcoord) at (axis cs:70,0.024);
|
|
|
|
\coordinate (plotAcoordY) at (axis cs:0,0.024);
|
|
|
|
\draw[plotA,thick, dashed](plotAcoord -| plotAcoordY) -- (plotAcoord);
|
|
|
|
|
|
|
|
\coordinate (plotBcoord) at (axis cs:70,0.0004);
|
|
|
|
\coordinate (plotBcoordY) at (axis cs:0,0.0004);
|
|
|
|
\draw[plotB,thick, dashed](plotBcoord -| plotBcoordY) -- (plotBcoord);
|
|
|
|
|
|
|
|
\node[above right=0cm and 0cm of plotAcoordY,color=red!90!black] (f1y) {$f_{I}(70)$};
|
|
|
|
\node[above right=0cm and 0cm of plotBcoordY,color=cyan!50!black] (f2y) {$f_{II}(70)$};
|
|
|
|
|
2014-08-13 12:27:59 -04:00
|
|
|
% Plots of the distributions
|
|
|
|
\addplot [domain=0:120,samples=200,plotA] {gauss(80,100)};
|
|
|
|
\addplot [domain=0:120,samples=200,plotB] {gauss(40,100)};
|
|
|
|
|
|
|
|
% Mark points
|
|
|
|
\addplot+[plotA,
|
|
|
|
samples at={70},
|
|
|
|
mark=*,
|
2014-08-20 20:54:02 -04:00
|
|
|
mark options={scale=1, fill=red!90!black}] {gauss(\meanI,\varI)};
|
2014-08-13 12:27:59 -04:00
|
|
|
\addplot+[plotB,
|
|
|
|
samples at={70},
|
|
|
|
mark=*,
|
2014-08-20 20:54:02 -04:00
|
|
|
mark options={scale=1, fill=cyan!50!black}] {gauss(\meanII,\varII)};
|
2014-08-13 12:27:59 -04:00
|
|
|
\coordinate (a) at (axis cs:70,0.024);
|
|
|
|
\draw[black,thick](a |- current plot begin) -- (a);
|
|
|
|
|
|
|
|
% Add labels
|
2014-08-20 20:54:02 -04:00
|
|
|
\node[plotA,above] at (axis cs:102,\labelheight){\Large $\mathcal{N}(\meanI,\varI)$};
|
|
|
|
\node[plotB,above] at (axis cs:20,\labelheight){\Large $\mathcal{N}(\meanII,\varII)$};
|
2015-10-14 14:25:34 +02:00
|
|
|
\end{axis}
|
2014-08-11 13:54:04 -04:00
|
|
|
\end{tikzpicture}
|
|
|
|
\end{preview}
|
|
|
|
\end{document}
|