# How to create a gaussian curve with pgfplot?

What I want:

This is what I have so far in terms of code:

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

\begin{tikzpicture}
\begin{axis}[every axis plot post/.append style={
mark=none,domain=-2:3,samples=50,smooth}, % All plots: from -2:2, 50 samples, smooth, no marks
axis x line*=bottom, % no box around the plot, only x and y axis
axis y line*=left, % the * suppresses the arrow tips
enlargelimits=upper] % extend the axes a bit to the right and top
\end{axis}
\end{tikzpicture}

-
–  Peter Grill Oct 26 '12 at 21:39
Possible Duplicate: Bell Curve/Gaussian Function in TikZ/PGF and Plotting bell shaped curve in TikZ-PGF. Please see if these answer your question as then we can close this as a duplicate. –  Peter Grill Oct 26 '12 at 21:40
Could you be more specific about what you're having problems with? All you need to do is adjust the parameter for the second gaussian to make it use the same expected value as the first. –  Jake Oct 26 '12 at 21:53
When you cut and past code form another place, you should provide that info in the question. As another comment pointed out, the code given in the question is directly copied form the first link I provided. –  Peter Grill Oct 26 '12 at 21:59
My apologies for not adhering to the proper question etiquette Mr. Grill. In terms of being specific, I guess I am having trouble producing the "flatter" of the two functions above. Also, I am unaware of how to add some directional arrows (labeled ones) to the graphs as depicted above. –  ealfons1 Oct 26 '12 at 22:05

One possibility:

\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=\small}]
\begin{axis}[every axis plot post/.append style={
mark=none,domain=-3:3,samples=50,smooth},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0,
xtick=\empty,
]
\node[pin=70:{$\hat{\theta}_1$}] at (axis cs:0.57,0.5) {};
\node[pin=70:{$\hat{\theta}_2$}] at (axis cs:1,0.25) {};
\node[pin=270:{$\theta=E(\hat{\theta}_1)=E(\hat{\theta}_2)$}] at (axis cs:0,0) {};