Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

What I want:

enter image description here

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
\addplot {\gauss{0}{0.5}};
\addplot {\gauss{1}{0.75}};
\end{axis}
\end{tikzpicture}
share|improve this question
1  
Welcome to TeX.SE. –  Peter Grill Oct 26 '12 at 21:39
2  
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
show 1 more comment

1 Answer

up vote 7 down vote accepted

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,
]
\addplot {\gauss{0}{0.5}};
\addplot {\gauss{0}{1}};
\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) {};
\draw[dashed] (axis description cs:0.5,0) -- (axis description cs:0.5,0.92);
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Amazing, thank you very much! –  ealfons1 Oct 26 '12 at 22:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.