如何用图形解释分布矩的直觉

如何用图形解释分布矩的直觉

我想创建一些图表来解释分布的(前四个)矩的含义(我的意思是:均值、方差、偏度、峰度)。目标是在统计学教学中使用它。

我不能 100% 确定这是否适合这里,因为我隐含地问了两个问题:如何最好地描绘这些时刻如何在 TeX 中绘制这个,朋友们。不幸的是,这些问题无法解开,所以我希望社区能够在这里提供创造性的意见。

我第一次尝试的结果粘贴在下面。我认为这可以大大改进。仍然缺少的是峰度的令人信服的描述(即,可以清楚地看到其他时刻保持不变),我觉得其他图可以从视觉上整洁中受益:

在此处输入图片描述

代码:

\documentclass[varwidth,margin=5px]{standalone}
\usepackage{pgfplots}
\begin{document}

\pgfmathdeclarefunction{gauss}{3}{%
    \pgfmathparse{1/(#3*sqrt(2*pi))*exp(-((#1-#2)^2)/(2*#3^2))}%
}
First moment (Location):\\
\begin{tikzpicture}
\begin{axis}[
        no markers
    , domain=-7.5:11.5
    , samples=100
    , ymin=0
    , axis lines*=left
    , xlabel= 
     , every axis y label/.style={at=(current axis.above origin),anchor=south}
    , every axis x label/.style={at=(current axis.right of origin),anchor=west}
    , height=5cm
    , width=15cm
    , xtick=\empty
    , ytick=\empty
    , enlargelimits=false
    , clip=false
    , axis on top
    , grid = major
    , hide y axis
    , hide x axis
    ]


% Normal Distribution 1
\addplot[blue, ultra thick] {gauss(x, 0, 1.75)};
\pgfmathsetmacro\valueA{gauss(0, 0, 1.75)}
\draw [dashed, thick, blue] (axis cs:0, 0) -- (axis cs:0, \valueA);
\node[below] at (axis cs:0, -0.02)  {\Large \textcolor{blue}{$\mu_{1}$}}; 
\draw[thick, blue] (axis cs:-0.0, -0.01) -- (axis cs:0.0, 0.01);

% Normal Distribution 2
\addplot[green, ultra thick] {gauss(x, 4, 1.75)};
\draw [dashed, thick, green] (axis cs:4, 0) -- (axis cs:4, \valueA);
\node[below] at (axis cs:4, -0.02)  {\Large \textcolor{green}{$\mu_{2}$}}; 
\draw[thick, green] (axis cs:4, -0.01) -- (axis cs:4, 0.01);

 \draw[orange, -latex, line width = 1pt] (axis cs:0,0.1) -- (axis cs:4,0.1)
                node[anchor = north east, pos=0.5, font=\footnotesize] {};
                \end{axis}
\end{tikzpicture}
\\
Second moment (Dispersion):\\
\begin{tikzpicture}
\begin{axis}[
        no markers
    , domain=-7.5:11.5
    , samples=100
    , ymin=0
    , axis lines*=left
    , xlabel= 
    , every axis y label/.style={at=(current axis.above origin),anchor=south}
    , every axis x label/.style={at=(current axis.right of origin),anchor=west}
    , height=5cm
    , width=15cm
    , xtick=\empty
    , ytick=\empty
    , enlargelimits=false
    , clip=false
    , axis on top
    , grid = major
    , hide y axis
    , hide x axis
    ]


% Normal Distribution 1
\addplot[blue, ultra thick] {gauss(x, 2, 1.25)};
\draw [dashed, thick, blue] (axis cs:0.85, 0) -- (axis cs:0.85, 0.20);
\draw [dashed, thick, blue] (axis cs:3.15, 0) -- (axis cs:3.15, 0.20);
\draw [dashed, latex-latex, thick, blue] (axis cs:0.9, 0.1) -- (axis cs:3.1, 0.10);
\node[below] at (axis cs:2, 0.1)  {\Large \textcolor{blue}{$\sigma_{1}$}}; 

% Normal Distribution 2
\addplot[green, ultra thick] {gauss(x, 2, 2.75)};
\draw [dashed, thick, green] (axis cs:5, 0) -- (axis cs:5, 0.083);
\draw [dashed, thick, green] (axis cs:-1, 0) -- (axis cs:-1, 0.083);
\draw [dashed, latex-latex, thick, green] (axis cs:-1, 0.05) -- (axis cs:5, 0.05);
\node[below] at (axis cs:2, 0.05)  {\Large \textcolor{green}{$\sigma_{2}$}}; 

\draw[orange, -latex, line width = 1pt] (axis cs:0.85,0.015) -- (axis cs:-1,0.015)  node[anchor = north east, pos=0.5, font=\footnotesize] {};
\draw[orange, -latex, line width = 1pt] (axis cs:3.15,0.015) -- (axis cs:5,0.015)  node[anchor = north east, pos=0.5, font=\footnotesize] {};
                \end{axis}
\end{tikzpicture}
\\Third moment (Skewness):\\
\begin{tikzpicture}[
        declare function={gamma(\z)=
        (2.506628274631*sqrt(1/\z) + 0.20888568*(1/\z)^(1.5) + 0.00870357*(1/\z)^(2.5) - (174.2106599*(1/\z)^(3.5))/25920 - (715.6423511*(1/\z)^(4.5))/1244160)*exp((-ln(1/\z)-1)*\z);},
        declare function={gammapdf(\x,\k,\theta) = \x^(\k-1)*exp(-\x/\theta) / (\theta^\k*gamma(\k));}
]
\begin{axis}[
        no markers
    , domain=-1:10.5
    , samples=100
    , ymin=0
    , axis lines*=left
    , xlabel= 
    , every axis y label/.style={at=(current axis.above origin),anchor=south}
    , every axis x label/.style={at=(current axis.right of origin),anchor=west}
    , height=5cm
    , width=15cm
    , xtick=\empty
    , ytick=\empty
    , enlargelimits=false
    , clip=true
    , axis on top
    , grid = major
    , hide y axis
    , hide x axis
    ]

% Normal Distribution 1
\addplot[blue, ultra thick] {gauss(x, 3.3, 1.25)};
\draw [dashed, thick, blue] (axis cs:3.3, 0) -- (axis cs:3.3, 0.33);

% Distribution 2
\addplot[green, ultra thick] {gammapdf(x,2,2)};
\draw [dashed, thick, green] (axis cs:3.32, 0) -- (axis cs:1.4, 0.167);


\draw[orange, -latex, line width = 1pt] (axis cs:3.3,0.15) -- (axis cs:2.15,0.095)  node[anchor = north east, pos=0.5, font=\footnotesize] {};

\draw[thick, blue] (axis cs:3.3, 0) -- (axis cs:3.6, 0.06);
\draw[thick, green] (axis cs:3.3, 0) -- (axis cs:3.6, 0.03);
\node[right] at (axis cs:3.6, 0.06)  {\Large \textcolor{blue}{$\mu_{1}$}}; 
\node[right] at (axis cs:3.6, 0.03)  {\Large \textcolor{green}{$\mu_{2}$}}; 

                \end{axis}
\end{tikzpicture}
\\Fourth moment (Kurtosis):\\
\begin{tikzpicture}[
        declare function={gamma(\z)=
        (2.506628274631*sqrt(1/\z) + 0.20888568*(1/\z)^(1.5) + 0.00870357*(1/\z)^(2.5) - (174.2106599*(1/\z)^(3.5))/25920 - (715.6423511*(1/\z)^(4.5))/1244160)*exp((-ln(1/\z)-1)*\z);},
        declare function={gammapdf2(\x,\k,\theta) = (\x*\x)^(\k-1)*exp(-\x*\x/\theta) / (\theta^\k*gamma(\k));}
]
\begin{axis}[
        no markers
    , domain=-0:10
    , samples=100
    , ymin=-0.001
    , axis lines*=left
    , xlabel= 
    , every axis y label/.style={at=(current axis.above origin),anchor=south}
    , every axis x label/.style={at=(current axis.right of origin),anchor=west}
    , height=5cm
    , width=15cm
    , xtick=\empty
    , ytick=\empty
    , enlargelimits=false
    , clip=true
    , axis on top
    , grid = major
    , hide y axis
    , hide x axis
    ]

% Normal Distribution 1
\addplot[blue, ultra thick] {gauss(x, 5, 1.25)};
\draw[dashed, thick, gray] (axis cs:5, 0) -- (axis cs:5, 0.33);

\draw[dashed,  gray] (axis cs:6.25, 0) -- (axis cs:6.25, 0.22);
\draw[dashed,  gray] (axis cs:3.75, 0) -- (axis cs:3.75, 0.22);

% Distribution 2
\draw[green, ultra thick]
     (axis cs:5, 0) ellipse [ x radius = 269, y radius = 250];   


\draw[dashed, latex-latex,  gray] (axis cs:3.75, 0.13) -- (axis cs:6.25, 0.13);
\node[below] at (axis cs:5.5, 0.13)  {\Large \textcolor{gray}{\small{$\sigma_{1}=\sigma_{2}$}}}; 

\draw[thick, gray] (axis cs:5, 0) -- (axis cs:5.3, 0.06);
\node[right] at (axis cs:5.3, 0.06)  {\Large \textcolor{gray}{\small{$\mu_{1}=\mu_{2}$}}}; 
                \end{axis}
\end{tikzpicture}

\end{document}

相关内容