normal-distribution-cumulative-density-function-many.tex 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. \documentclass[varwidth=true, border=4pt]{article}
  2. \usepackage[active,tightpage]{preview}
  3. \usepackage[latin1]{inputenc}
  4. \usepackage{amsmath}
  5. \usepackage{pgfplots}
  6. \usepackage{helvet}
  7. \usepackage[eulergreek]{sansmath}
  8. \def\cdf(#1)(#2)(#3){0.5*(1+(erf((#1-#2)/(sqrt(#3*2)))))}%
  9. % to be used: \cdf(x)(mean)(variance)
  10. \DeclareMathOperator{\CDF}{cdf}
  11. \pgfplotsset{
  12. tick label style = {font=\sansmath\sffamily},
  13. every axis label/.append style={font=\sffamily\footnotesize},
  14. }
  15. \begin{document}
  16. \begin{preview}
  17. \begin{tikzpicture}
  18. \begin{axis}[
  19. width=13.5cm,
  20. height=8.625cm,
  21. % Grid
  22. grid = major,
  23. grid style={black, thin},
  24. % size
  25. xmin=-5.25, % start the diagram at this x-coordinate
  26. xmax= 5.25, % end the diagram at this x-coordinate
  27. ymin=-0.05, % start the diagram at this y-coordinate
  28. ymax= 1.05, % end the diagram at this y-coordinate
  29. % Legende
  30. legend pos=north west,
  31. legend style={font=\footnotesize},
  32. % Ticks
  33. tick align=inside,
  34. minor tick num=3,
  35. minor tick style={thick},
  36. yticklabel style={
  37. /pgf/number format/precision=1,
  38. /pgf/number format/fixed,
  39. /pgf/number format/fixed zerofill},
  40. % Axis
  41. axis line style = very thick,
  42. xlabel=$x$,
  43. x label style={at={(axis description cs:0.5,0)},
  44. anchor=north,
  45. font=\boldmath\Large},
  46. ylabel=$\Phi_{\mu, \sigma^2}(x)$,
  47. y label style={at={(axis description cs:0.05,0.5)},
  48. anchor=south,
  49. font=\boldmath\Large},
  50. ]
  51. \addplot[domain=-5.25:5.25,smooth,blue!70!black,ultra thick,samples=200,] gnuplot{\cdf(x)(0)(0.2)};
  52. \addplot[domain=-5.25:5.25,smooth,red!70!black,ultra thick,samples=200,] gnuplot{\cdf(x)(0)(1.0)};
  53. \addplot[domain=-5.25:5.25,smooth,yellow!80!black,ultra thick,samples=200,] gnuplot{\cdf(x)(0)(5)};
  54. \addplot[domain=-5.25:5.25,smooth,green!70!black,ultra thick,samples=200,] gnuplot{\cdf(x)(-2)(0.5)};
  55. \addlegendentry{$\mu=\hphantom{-}0,\quad \sigma^2 = 0.2$}
  56. \addlegendentry{$\mu=\hphantom{-}0,\quad \sigma^2 = 1.0$}
  57. \addlegendentry{$\mu=\hphantom{-}0,\quad \sigma^2 = 5.0$}
  58. \addlegendentry{$\mu=-2,\quad \sigma^2 = 0.5$}
  59. \end{axis}
  60. \end{tikzpicture}
  61. \end{preview}
  62. \end{document}