2.2 KiB
2.2 KiB
id, aliases, title, tags
| id | aliases | title | tags | |||||
|---|---|---|---|---|---|---|---|---|
| Decrease in Sigma |
|
Decrease in Sigma
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=13cm,
height=7cm,
axis lines=middle,
xlabel={$x$},
ylabel={$\varphi(x;\mu,\sigma)$},
xmin=-6, xmax=6,
ymin=0, ymax=0.85,
samples=400,
domain=-6:6,
legend style={draw=none, fill=none, at={(0.98,0.98)}, anchor=north east},
legend cell align=left,
ytick=\empty,
]
% Normal PDF: (1/(sigma*sqrt(2*pi))) * exp(-(x-mu)^2/(2*sigma^2))
\addplot[thick]
{ (1/(1.8*sqrt(2*pi))) * exp(-((x-0.8)^2)/(2*1.8^2)) };
\addlegendentry{$\mu=0,\ \sigma=1.8$}
\addplot[thick, dashed]
{ (1/(0.8*sqrt(2*pi))) * exp(-((x-0.8)^2)/(2*0.8^2)) };
\addlegendentry{$\mu=0,\ \sigma=0.8$}
\end{axis}
\end{tikzpicture}
\end{document}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\pgfmathdeclarefunction{erfapprox}{1}{%
\pgfmathparse{%
% save sign and work with |x|
( (#1<0) ? -1 : 1 )
* ( 1 - (1 + 0.278393*abs(#1) + 0.230389*abs(#1)^2 + 0.000972*abs(#1)^3 + 0.078108*abs(#1)^4)^(-4) )
}%
}
% Normal CDF using erf approximation:
% F(x;mu,sigma) = 0.5*(1 + erf((x-mu)/(sigma*sqrt(2))))
\pgfmathdeclarefunction{normcdf}{3}{%
\pgfmathparse{ 0.5*(1 + erfapprox((#1-#2)/(#3*sqrt(2)))) }%
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=13cm,
height=7cm,
axis lines=middle,
xlabel={$x$},
ylabel={$F(x;\mu,\sigma)$},
xmin=-6, xmax=6,
ymin=0, ymax=1.05,
samples=400,
domain=-6:6,
legend style={draw=none, fill=none, at={(0.02,0.98)}, anchor=north west},
legend cell align=left,
ytick={0,0.5,1},
]
% Normal CDF: 0.5*(1 + erf((x-mu)/(sigma*sqrt(2))))
\addplot[thick]
{ normcdf(x,0,1.8) };
\addlegendentry{$\mu=0,\ \sigma=1.8$}
\addplot[thick, dashed]
{ normcdf(x,0.8) };
\addlegendentry{$\mu=0,\ \sigma=0.8$}
\end{axis}
\end{tikzpicture}
\end{document}