lda-gauss-2.tex 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. \pgfplotsset{
  15. tick label style = {font=\sansmath\sffamily},
  16. every axis label/.append style={font=\sffamily\footnotesize},
  17. }
  18. \begin{document}
  19. \begin{preview}
  20. \tikzstyle{plotA}=[ultra thick,red!90!black]
  21. \tikzstyle{plotB}=[ultra thick,cyan!50!black]
  22. \begin{tikzpicture}
  23. \begin{axis}[
  24. width=13.5cm,
  25. height=8.625cm,
  26. % Grid
  27. grid = major,
  28. %grid style={thin, dashed},
  29. % size
  30. xmin= 0, % start the diagram at this x-coordinate
  31. xmax= 125, % end the diagram at this x-coordinate
  32. ymin= 0, % start the diagram at this y-coordinate
  33. ymax= 0.045, % end the diagram at this y-coordinate
  34. % Legende
  35. legend style={
  36. font=\large\sansmath\sffamily,
  37. at={(0.5,-0.18)},
  38. anchor=north,
  39. legend cell align=left,
  40. legend columns=-1,
  41. column sep=0.5cm
  42. },
  43. % Ticks
  44. tick align=inside,
  45. %minor tick num=3,
  46. minor tick style={thick},
  47. scaled y ticks = false,
  48. % xtick={40,70,80},
  49. ytick=\empty,
  50. % Axis
  51. axis lines = middle,
  52. axis line style = very thick,
  53. xlabel=$x$,
  54. x label style={at={(axis description cs:0.52,0)},
  55. anchor=north,
  56. font=\boldmath\Large},
  57. ylabel=$f(x)$,
  58. y label style={at={(axis description cs:0,0.5)},
  59. anchor=south,
  60. rotate=90,
  61. font=\boldmath\Large},
  62. ]
  63. % Plots of the distributions
  64. \addplot [domain=0:120,samples=200,plotA] {gauss(60,800)};
  65. \addplot [domain=0:120,samples=200,plotB] {gauss(40,100)};
  66. % Add labels
  67. \node[plotA,above] at (axis cs:102,0.01){\Large $\mathcal{N}(60, 800)$};
  68. \node[plotB,above] at (axis cs:20,0.03){\Large $\mathcal{N}(40, 100)$};
  69. % \addlegendentry{$\mu=80,\enskip \sigma^2 = 100$}
  70. % \addlegendentry{$\mu=40,\enskip \sigma^2 = 100$}
  71. \end{axis}
  72. \end{tikzpicture}
  73. \end{preview}
  74. \end{document}