normal_dist

../_images/sphx_glr_normal_dist.svg
\documentclass[]{standalone}

\usepackage[]{graphicx}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\tikzset{>=latex}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\usepackage{subcaption}



\newcommand*{\equal}{=}

\usepackage{tikz-3dplot}
\usetikzlibrary{decorations.markings}

\tikzset{->-/.style={decoration={
  markings,
  mark=at position #1 with {\arrow{>}}},postaction={decorate}}}

\begin{document}

%\begin{subfigure}{.5\textwidth}
%\centering
\begin{tikzpicture}[/pgfplots/tick scale binop=\times]
\begin{axis}[
axis y line=left, axis x line=bottom,
width=0.8\textwidth,
ymin = -0.0, ymax = 0.18,
xtick={145, 150, ..., 170},
ticklabel style={font=\footnotesize},
label style={font=\small},
xlabel={$x$},
ylabel={$f(x)$},
clip=false
]
  \addplot [domain=141:175,samples=100, name path=f, black,very thick] {exp(-(x-157.8)^2/(2*5.4^2))/sqrt(2*pi*5.4^2)};
  \path[name path=axis] (axis cs:139,0) -- (axis cs:175,0);
  \addplot [
     very thick,
     color=black,
     pattern=north east lines, 
  ] fill between[
    of=f and axis,
    soft clip={domain=141:148},
  ];
  \draw[very thick, <-] (axis cs:148, 0.0) -- (axis cs:148, -0.012) node[below] {\footnotesize{\alpha}};    
\end{axis}
\end{tikzpicture}%
%\caption{$N(157.8, 5.4^2)$の確率密度関数.図の斜線部の面積が$P(154\le\alpha)=0.04$}
%\end{subfigure}
\hspace{5mm}
%\begin{subfigure}{.5\textwidth}
\centering
\begin{tikzpicture}[/pgfplots/tick scale binop=\times]
\begin{axis}[
axis y line=middle, axis x line=bottom,
width=0.8\textwidth,
ymin = -0.0, ymax = 0.45,
xtick = {-2, -1, ..., 2},
%xmin = -3.5, xmax=3.5,
%ytick=\empty,
ticklabel style={font=\footnotesize},
label style={font=\small},
xlabel={$z$},
ylabel={$f_s(z)$},
clip=false
]
  \addplot [domain=-3.5:3.5,samples=100, name path=f, black,very thick] {exp(-x^2/2)/sqrt(2*pi)};
  \path[name path=axis] (axis cs:-3.5,0) -- (axis cs:3.5,0);
  \addplot [
     very thick,
     color=black,
     pattern=north east lines, 
%     fill=red, 
%     fill opacity=0.5
  ] fill between[
    of=f and axis,
    soft clip={domain=-3.5:-1.7507},
  ];
  \addplot [
     very thick,
     color=black,
     pattern=north east lines, 
  ] fill between[
    of=f and axis,
    soft clip={domain=1.7507:3.5},
  ];  
  \addplot [
     fill=red, 
     fill opacity=0.5
  ] fill between[
    of=f and axis,
    soft clip={domain=-3.5:1.7507},
  ];
  
  \draw[thick, <-] (axis cs:-1.7507, 0.0) -- (axis cs:-1.7507, -0.03) node[below] {\footnotesize{-\beta}};   
  \draw[thick, <-] (axis cs:1.7507, 0.0) -- (axis cs:1.7507, -0.03) node[below] {\footnotesize{\beta}};     
\end{axis}
\end{tikzpicture}
%\caption{$N(0,1^2)$の確率密度関数.左右の斜線部の面積がそれぞれ0.04,赤色の面積が0.96}
%\end{subfigure}

\end{document}