normal-distribution-cumulative-density-function.tex 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. \documentclass[varwidth=true, border=2pt]{standalone}
  2. \usepackage{amsmath}
  3. \usepackage{pgfplots}
  4. \def\cdf(#1)(#2)(#3){0.5*(1+(erf((#1-#2)/(#3*sqrt(2)))))}%
  5. % to be used: \cdf(x)(mean)(variance)
  6. \DeclareMathOperator{\CDF}{cdf}
  7. \begin{document}
  8. \begin{tikzpicture}
  9. \begin{axis}[
  10. legend pos=north west,
  11. axis x line=middle,
  12. axis y line=middle,
  13. grid = major,
  14. width=8cm,
  15. height=6cm,
  16. grid style={dashed, gray!30},
  17. xmin=-5.1, % start the diagram at this x-coordinate
  18. xmax= 5.1, % end the diagram at this x-coordinate
  19. ymin= 0, % start the diagram at this y-coordinate
  20. ymax= 1.1, % end the diagram at this y-coordinate
  21. %axis background/.style={fill=white},
  22. x label style={at={(axis description cs:0.5,0)},anchor=north},
  23. y label style={at={(axis description cs:0,.5)},rotate=90,anchor=south},
  24. xlabel=$x$,
  25. ylabel=$\Phi_{\mu, \sigma^2}(x)$,
  26. %xticklabels={-2,-1.6,...,7},
  27. %yticklabels={-8,-7,...,8},
  28. tick align=outside,
  29. minor tick num=-3,
  30. enlargelimits=false,
  31. tension=0.08]
  32. \addplot[domain=-5.2:5.2,smooth,red!70!black,very thick,samples=200,] gnuplot{\cdf(x)(0)(1)};
  33. \addlegendentry{$\sigma^2 = 1$}
  34. \end{axis}
  35. \end{tikzpicture}
  36. \end{document}