I wants to make PDF diagram like that.
currently, i'm here. Can someone please help me out to complete the diagram further. Thanks in advance.
\documentclass{article}
\usepackage{pgfplots}
\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=-5:5, samples=100,
axis lines*=left, xlabel=$x$, ylabel=$y$,
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=12cm,
xtick={-1,+1}, ytick=\empty,
enlargelimits=false, clip=false, axis on top,
grid = major
]
\addplot [fill=black!20, draw=none, domain=-2.5:0] {gauss(+1,1)} \closedcycle ;
\addplot [fill=black!20, draw=none, domain=0:+2.5] {gauss(-1,1)} \closedcycle ;
\addplot [very thick,black!50!black] {gauss(-1,1)};
\addplot [very thick,black!50!black] {gauss(+1,1)};
\draw (-.2,2.5) node[left] {$f_Y(u)$};
\draw (3,-.5) node[below] {$u$};
\draw[->] (0,0) -- (6.2,0) node[right] {};
\draw[->] (0,0) -- (0,5) node[above] {};
\draw [yshift=-0.6cm, latex-latex](axis cs:0,0) -- node [fill=white] {$1.96\sigma$} (axis cs:0,0);
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
This might help towards your objective. I leave it to you to do the notation across the x-axis, since there is nothing to indicate the size of each interval.
The graph uses the
fill between
library frompgfplots
to produce the filled areas. I defined some variables for the key parameters, which will make it easier for you to customize.This is the result:
This is the code: