tikz를 사용하여 2자유도 분포 그리기

tikz를 사용하여 2자유도 분포 그리기

내 코드는 다음과 같습니다.

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.14, label style={font=\huge}, tick label style={font=\huge}}
\usepgfplotslibrary{fillbetween}
\begin{document}

\pgfmathdeclarefunction{t_dist}{1}{%
  \pgfmathparse{gamma((#1 + 1)/2)/(\sqrt(#1*pi)*gamma(#1/2))*(1 + (x^2/#1))^(-(#1+1)/2)}%
}

\begin{tikzpicture}
\begin{axis}[
  no markers, domain=-3.5:3.5, samples=300,
  axis x line=bottom, axis y line=left,
  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=14cm,
  xtick={-3.5, -1.5, 0, 3.5}, ytick=\empty,
  enlargelimits=false, clip=false, axis on top,
  xticklabels={-$\infty$, -3, 0, $\infty$}, %  so do it manually instead
  ]

  \addplot [very thick,blue, name path=f] {t_dist(2)}; 
  \path[name path=axis](axis cs:--3.5,0) -- (axis cs:-3,0);
  \addplot[thick, color=blue, fill=blue, fill opacity=0.5] fill between [of=f and axis, soft clip={domain=-3.5:-1.5},];
  
\end{axis}

\end{tikzpicture}
\end{document}

정규 분포를 사용할 때는 잘 작동하지만 t 분포의 경우 23행에서 "정의되지 않은 제어 순서"라는 오류가 발생합니다.

여기에일하고 있는정규 분포를 따르는 코드:

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.14, label style={font=\huge}, tick label style={font=\huge}}
\usepgfplotslibrary{fillbetween}
\begin{document}

\pgfmathdeclarefunction{gauss}{2}{%
  \pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}

\begin{tikzpicture}
\begin{axis}[
  no markers, domain=-3.5:3.5, samples=300,
  axis x line=bottom, axis y line=left,
  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=14cm,
  xtick={-3.5, -1.5, 0, 3.5}, ytick=\empty,
  enlargelimits=false, clip=false, axis on top,
  xticklabels={-$\infty$, -3, 0, $\infty$},
  ]

  \addplot [very thick,blue, name path=f] {gauss(0,1)};
  \path[name path=axis](axis cs:--3.5,0) -- (axis cs:-3,0);
  \addplot[thick, color=blue, fill=blue, fill opacity=0.5] fill between [of=f and axis, soft clip={domain=-3.5:-1.5},];
  
\end{axis}

\end{tikzpicture}
\end{document}

tikz를 사용하여 2자유도 분포를 어떻게 플롯할 수 있나요?

관련 정보