有人可以帮助我绘制以下函数(带标签)吗?

有人可以帮助我绘制以下函数(带标签)吗?

pgfplots这是我以前关于使用以下链接绘制一对函数图形的问题的延伸:

如何使用 pgfplot 创建高斯曲线?

我正在尝试使用之前给出的解决方案中的代码来生成以下函数(带标签等/无阴影)以下:

高斯图像

然而,我遇到了麻烦,并得到了其他东西。到目前为止,这是我在代码方面得出的结论:

\begin{tikzpicture}[
every pin edge/.style={<-},
every pin/.style={fill=yellow!50,rectangle,rounded corners=3pt,font=\small}]
\begin{axis}[every axis plot post/.append style={
  mark=none,domain=-5:5,samples=50,smooth},
clip=false,
axis lines=none
]
\addplot {\gauss{-1.5}{1}};
\addplot {\gauss{1}{3}};
\addplot {\gauss{3}{3.1}};
\node[pin=70:{Most efficient: p(v) has lease MSE}] at (axis description cs:0.47,0.6) {};
\node[pin=70:{p(u) has the lease bias}] at (axis description cs:0.65,0.3) {};
\node[pin=70:{p(w) has the lease variance}] at (axis description cs:0.85,0.3) {};
\node[pin=270:{$\theta$}] at (axis description cs:0.5,0.1) {};
\draw[dashed] (axis description cs:0.5,0) -- (axis description cs:0.5,0.92);
\end{axis}
\end{tikzpicture}

答案1

这是一种可能性;这一次,我使用了axis cs坐标系(我不确定 theta 和它的箭头的位置,因为原始图纸在这部分不清楚):

\documentclass{article}
\usepackage{pgfplots}

\newcommand\gauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))} 
% Gauss function, parameters mu and sigma

\begin{document}

\begin{tikzpicture}[
every pin edge/.style={<-},
every pin/.style={fill=yellow!50,rectangle,
  rounded corners=3pt,font=\footnotesize},
mylabel/.style={fill=yellow!50,rectangle,
  rounded corners=3pt,font=\footnotesize,align=center}]
\begin{axis}[every axis plot post/.append style={
  mark=none,domain=-8:20,samples=50,smooth},
clip=false,
axis lines=none,
]

\def\puxpos{1}
\def\pvxpos{2.5}
\def\pwxpos{16}

\addplot {\gauss{\puxpos}{3}};
\addplot {\gauss{\pvxpos}{1}};
\addplot {\gauss{\pwxpos}{0.75}};

\draw[dashed] (axis cs:\pvxpos,0) -- (axis cs:\pvxpos,0.4);
\draw[dashed] (axis cs:\pwxpos,0) -- (axis cs:\pwxpos,0.5);

\node[pin=270:{$\theta$}] at (axis cs:1,0.065) {};
\node[mylabel] at (axis cs:\pvxpos,0.48) (pv) {MOST EFFICIENT \\ $V$ has least MSE \\ $p(v)$};
\node[mylabel] at (axis cs:-8.4,0.09) (pu) {$U$ has \\least bias \\ $p(u)$};
\node[mylabel] at (axis cs:\pwxpos,0.62) (pw) {$W$ has \\ least variance \\ $p(w)$};
\end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容