lda-gauss-intervariance.tex 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. \documentclass[varwidth=true, border=5pt]{article}
  2. \usepackage[active,tightpage]{preview}
  3. \usepackage[latin1]{inputenc}
  4. \usepackage{amsmath}
  5. \usepackage{pgfplots}
  6. \usepackage{tikz}
  7. \usetikzlibrary{arrows,positioning}
  8. \usepackage{helvet}
  9. \usepackage[eulergreek]{sansmath}
  10. \pgfmathdeclarefunction{gauss}{2}{%
  11. \pgfmathparse{1/(sqrt(2*pi*#2))*exp(-((x-#1)^2)/(2*#2))}%
  12. }
  13. % to be used: \gauss(x)(mean)(variance)
  14. \makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother
  15. \pgfplotsset{
  16. tick label style = {font=\sansmath\sffamily},
  17. every axis label/.append style={font=\sffamily\footnotesize},
  18. }
  19. \pgfplotsset{axis line on top/.style={
  20. axis line style=transparent,
  21. ticklabel style=transparent,
  22. tick style=transparent,
  23. axis on top=false,
  24. after end axis/.append code={
  25. \pgfplotsset{axis line style=opaque,
  26. ticklabel style=opaque,
  27. tick style=opaque,
  28. grid=none}
  29. \pgfplotsdrawaxis}
  30. }
  31. }
  32. \tikzset{>=latex}
  33. \begin{document}
  34. \begin{preview}
  35. \tikzstyle{plotA}=[ultra thick,red!90!black]
  36. \tikzstyle{plotB}=[ultra thick,cyan!50!black]
  37. \begin{tikzpicture}
  38. \begin{axis}[
  39. width=13.5cm,
  40. height=8.625cm,
  41. % Grid
  42. grid = major,
  43. grid style={thin, dashed},
  44. % size
  45. xmin= 20, % start the diagram at this x-coordinate
  46. xmax= 105, % end the diagram at this x-coordinate
  47. ymin= 0, % start the diagram at this y-coordinate
  48. ymax= 0.07, % end the diagram at this y-coordinate
  49. % Legende
  50. legend style={
  51. font=\large\sansmath\sffamily,
  52. at={(0.5,-0.18)},
  53. anchor=north,
  54. legend cell align=left,
  55. legend columns=-1,
  56. column sep=0.5cm
  57. },
  58. % Ticks
  59. tick align=inside,
  60. scaled y ticks = false,
  61. %xtick={20,30,...,100},
  62. ytick=\empty,
  63. % Axis
  64. axis lines = middle,
  65. axis line style = very thick,
  66. axis line on top,
  67. axis line style = {very thick,shorten <=-0.5\pgflinewidth},
  68. xlabel=$x$,
  69. x label style={at={(axis description cs:0.52,0)},
  70. anchor=north,
  71. font=\boldmath\Large},
  72. ylabel=$f(x)$,
  73. y label style={at={(axis description cs:0,0.5)},
  74. anchor=south,
  75. rotate=90,
  76. font=\boldmath\Large},
  77. ]
  78. % Mark means
  79. \coordinate (axisOrigin) at (axis cs:0,0);
  80. \coordinate (meanA) at (axis cs:50,0.063);
  81. \draw[black,thick](meanA |- axisOrigin) -- (meanA);
  82. \coordinate (meanB) at (axis cs:40,0.063);
  83. \draw[black,thick](meanB |- axisOrigin) -- (meanB);
  84. \draw[black,ultra thick,<->](axis cs:40,0.007) -- (axis cs:50,0.007);
  85. % Plots of the distributions
  86. \addplot [domain=0:100,samples=400,plotA] {gauss(50,40)};
  87. \addplot [domain=0:100,samples=400,plotB] {gauss(40,40)};
  88. % Add labels
  89. \node[plotA,above] at (axis cs:63,0.055){\Large $\mathcal{N}(50, 40)$};
  90. \node[plotB,above] at (axis cs:28,0.055){\Large $\mathcal{N}(40, 40)$};
  91. \end{axis}
  92. \end{tikzpicture}
  93. \end{preview}
  94. \end{document}