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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 style={
  31. font=\large\sansmath\sffamily,
  32. at={(0.7716,0.41)},
  33. anchor=north,
  34. legend cell align=left
  35. },
  36. % Ticks
  37. tick align=inside,
  38. minor tick num=3,
  39. minor tick style={thick},
  40. yticklabel style={
  41. /pgf/number format/precision=1,
  42. /pgf/number format/fixed,
  43. /pgf/number format/fixed zerofill},
  44. % Axis
  45. axis line style = very thick,
  46. xlabel=$x$,
  47. x label style={at={(axis description cs:0.5,0)},
  48. anchor=north,
  49. font=\boldmath\Large},
  50. ylabel=$\Phi_{\mu, \sigma^2}(x)$,
  51. y label style={at={(axis description cs:0.05,0.5)},
  52. anchor=south,
  53. font=\boldmath\Large},
  54. ]
  55. \addplot[domain=-5.25:5.25,smooth,blue!70!black,ultra thick,samples=200,] gnuplot{\cdf(x)(0)(0.2)};
  56. \addplot[domain=-5.25:5.25,smooth,red!70!black,ultra thick,samples=200,] gnuplot{\cdf(x)(0)(1.0)};
  57. \addplot[domain=-5.25:5.25,smooth,yellow!80!black,ultra thick,samples=200,] gnuplot{\cdf(x)(0)(5)};
  58. \addplot[domain=-5.25:5.25,smooth,green!70!black,ultra thick,samples=200,] gnuplot{\cdf(x)(-2)(0.5)};
  59. \addlegendentry{$\mu=\hphantom{-}0,\enskip \sigma^2 = 0.2$}
  60. \addlegendentry{$\mu=\hphantom{-}0,\enskip \sigma^2 = 1.0$}
  61. \addlegendentry{$\mu=\hphantom{-}0,\enskip \sigma^2 = 5.0$}
  62. \addlegendentry{$\mu=-2,\enskip \sigma^2 = 0.5$}
  63. \end{axis}
  64. \end{tikzpicture}
  65. \end{preview}
  66. \end{document}