\documentclass{article}
\usepackage{dsfont}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\spanishdecimal{\raisebox{1.4ex}{,}}
\usepackage{amsmath}
\usepackage{amsthm}  % para theoremstyle
\usepackage{amssymb} % para leqslant
%% https://tex.stackexchange.com/questions/43610/
%% plotting-bell-shaped-curve-in-tikz-pgf
\usepackage{pgfplots} 
\pgfmathdeclarefunction{gauss}{2}{% mu, sigma
  \pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\theoremstyle{definition}
\newtheorem{definicion}{Definición}
\newtheorem{ejemplo}{Ejemplo}
\newtheorem{teorema}{Teorema}
\newcommand{\contraste}[2]{
  \begin{array}{ll}
    H_0\colon&{#1}\\H_1\colon&{#2}
  \end{array}
}
\renewcommand{\(}{\left(}
\renewcommand{\)}{\right)}
\renewcommand{\[}{\left[}
\renewcommand{\]}{\right]}
\renewcommand{\le}{\leqslant}
\renewcommand{\ge}{\geqslant}
\renewcommand{\P}[1]{\Pr\[#1\]}
\newcommand{\condic}{\;\middle|\;}
\newcommand{\Pc}[2]{\P{#1\condic{}#2}}
\newcommand{\conjuntoc}[2]{\left\{#1\condic{}#2\right\}}
\newcommand{\RC}[1]{\conjuntoc{\vec x}{#1}}
\newcommand{\funcion}[2]{#1\left(#2\right)}
\newcommand{\funcionc}[3]{#1\left(#2\condic{}#3\right)}
\newcommand{\uno}[1]{\funcion{\mathds{1}}{#1}}
\newcommand{\sigue}{\mathbin{\hookrightarrow}}
\newcommand{\distuno}[2]{#1\left(#2\right)}
\newcommand{\distdos}[3]{#1\left(#2,#3\right)}
\newcommand{\gaus}[2]{\distdos{\mathcal{N}}{#1}{#2}}
\newcommand{\unif}[2]{\distdos{\mathcal{U}}{#1}{#2}}
\newcommand{\expo}[1]{\distuno{\text{Exp}}{#1}}
\newcommand{\gama}[2]{\distdos{\gamma}{#1}{#2}}
\newcommand{\bernuli}[1]{\distuno{\mathcal{B}}{#1}}
\newcommand{\binomial}[2]{\distdos{\mathcal{B}}{#1}{#2}}
\newcommand{\fc}[2]{f\left(#1\condic{}#2\right)}
\newcommand{\E}[1]{E\left(#1\right)}
\newcommand{\Ec}[2]{\E{#1\condic{}#2}}
\newcommand{\pot}[1]{\funcion{\text{Pot}}{#1}}
\newcommand{\Pot}[2]{\funcion{\text{Pot}_{#1}}{#2}}

\begin{document}
\title{Contrastes bilaterales}
\maketitle
Los procedimientos vistos hasta ahora aseguraban la existencia del
contraste uniformemente más potente en casos unilaterales.
Para el caso bilateral no existe un resultado tan general.
\begin{ejemplo}
  Sea $X\sigue\gaus{\mu}{1}$ y considérese el contraste
  $$
  \contraste{\mu=\mu_0}{\mu\neq\mu_0}
  $$
  Sea $\varphi$ el contraste intuitivo con región crítica
  $$
  \RC{\left|\frac{\bar x-\mu_0}{1/\sqrt n}\right|>z_{1-\frac\alpha2}}
  $$
  Por ejemplo, con $\mu_0=0$, $n=25$ y $\alpha=0.05$,
  $$\text{R.C.} =
  \RC{|5\bar x|>1.96}=
  \RC{|\bar x|>0.392}
  $$    
  Entonces su potencia en $\mu=0.5$ es
  $$
  \Pc{|\bar x|>0.392}{\mu=0.5}=
  \P{\left|\gaus{0.5}{0.2}\right|>0.392}=
  $$
  $$
  =\P{\gaus{0.5}{0.2}>0.392}+
  \P{\gaus{0.5}{0.2}<-0.392}=0.7054
  $$
  Sea el contraste $\varphi'$ con región crítica
  $$
  \RC{\frac{\bar x-\mu_0}{1/\sqrt n}>z_{1-\alpha}}
  =\RC{\bar x>0.329}
  $$
  Entonces su potencia en $\mu=0.5$ es
  $$
  \Pc{\bar x>0.329}{\mu=0.5}=0.8037
  $$
  Luego $\varphi'$ es más potente que $\varphi$ en $0.5$,
  pero no lo será para valores $\mu<\mu_0$.
\end{ejemplo}
En el caso bilateral tendremos que restringir la clase de contrastes.
\begin{definicion}
  Un contraste $\varphi$ con nivel de significación $\alpha$
  se dice \emph{insesgado} si $\forall\,\theta\in\Theta_1$,
  $\Ec{\varphi}{\theta}\ge\alpha$.
\end{definicion}
Es decir, la probabilidad de rechazar $H_0$ cuando es falsa es siempre
mayor (o igual) que cuando es verdadera.
\begin{ejemplo}
  En el ejemplo anterior, $\varphi$ es insesgado pero $\varphi'$ no:

  \bigskip$\varphi$\bigskip

  \bigskip$H_0$\bigskip

  \begin{tikzpicture}
    \begin{axis}
      [no markers, domain=-5:5, samples=100,
      axis lines*=left, xlabel=$\bar X-\mu_0\over\sigma/\sqrt n$, ylabel=$ $,
      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=20ex, width=\textwidth,
      xtick={-1.96,0,1.96},
      xticklabels={$-z_{1-{\frac\alpha2}}$,$0$,$z_{1-{\frac\alpha2}}$},
      ytick=\empty,
      enlargelimits=false, clip=false, axis on top,
      grid = major]
      \addplot [fill=cyan!20, draw=none, domain=-5:-1.96]
               {gauss(-0,1)} \closedcycle;
      \addplot [fill=cyan!20, draw=none, domain=1.96:5]
               {gauss(-0,1)} \closedcycle;
      \addplot [very thick,cyan!50!black] {gauss(-0,1)};
    \end{axis}
  \end{tikzpicture}

  \bigskip$H_1$\bigskip

  \begin{tikzpicture}
    \begin{axis}
      [no markers, domain=-5:5, samples=100,
      axis lines*=left, xlabel=$\bar X-\mu_0\over\sigma/\sqrt n$, ylabel=$ $,
      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=20ex, width=\textwidth,
      xtick={-1.96,-1,0,1.645},
      xticklabels={-$z_{1-{\frac\alpha2}}$,$\frac{\mu-\mu_0}{\sigma/\sqrt n}$,
        $0$,$z_{1-{\frac\alpha2}}$},
      ytick=\empty,
      enlargelimits=false, clip=false, axis on top,
      grid = major]
      \addplot [fill=cyan!20, draw=none, domain=-5:-1.96]
               {gauss(-1,1)} \closedcycle;
      \addplot [fill=cyan!20, draw=none, domain=1.96:5]
               {gauss(-1,1)} \closedcycle;
      \addplot [very thick,cyan!50!black] {gauss(-1,1)};
    \end{axis}
  \end{tikzpicture}
  
  \bigskip$\varphi'$\bigskip
  
  \bigskip$H_0$\bigskip

  \begin{tikzpicture}
    \begin{axis}
      [no markers, domain=-5:5, samples=100,
      axis lines*=left, xlabel=$\bar X-\mu_0\over\sigma/\sqrt n$, ylabel=$ $,
      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=20ex, width=\textwidth,
      xtick={-0,0,1.645}, xticklabels={$$,$0$,$z_{1-{\alpha}}$},
      ytick=\empty,
      enlargelimits=false, clip=false, axis on top,
      grid = major]
      \addplot [fill=cyan!20, draw=none, domain=1.645:5]
               {gauss(-0,1)} \closedcycle;
      \addplot [very thick,cyan!50!black] {gauss(-0,1)};
    \end{axis}
  \end{tikzpicture}

  \bigskip$H_1$\bigskip

  \begin{tikzpicture}
    \begin{axis}
      [no markers, domain=-5:5, samples=100,
      axis lines*=left, xlabel=$\bar X-\mu_0\over\sigma/\sqrt n$, ylabel=$ $,
      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=20ex, width=\textwidth,
      xtick={-1,0,1.645}, xticklabels={$\frac{\mu-\mu_0}{\sigma/\sqrt n}$,
        $0$,$z_{1-{\alpha}}$},
      ytick=\empty,
      enlargelimits=false, clip=false, axis on top,
      grid = major]
      \addplot [fill=cyan!20, draw=none, domain=1.645:5]
               {gauss(-1,1)} \closedcycle;
      \addplot [very thick,cyan!50!black] {gauss(-1,1)};
    \end{axis}
  \end{tikzpicture}
\end{ejemplo}

\begin{ejemplo}
  Mismo ejemplo, usando como estadístico $\bar X$ en vez de
  $\bar X - \mu_0 \over \sigma/\sqrt n$.

  \bigskip$\varphi$\bigskip

  \bigskip$H_0$\bigskip

  \begin{tikzpicture}
    \begin{axis}
      [no markers, domain=-5:5, samples=100,
      axis lines*=left, xlabel=$\bar X$, ylabel=$ $,
      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=20ex, width=\textwidth,
      xtick={-1.96,0,1.96},
      xticklabels={$\mu_0-z_{1-{\frac\alpha2}}\frac\sigma{\sqrt n}$,
        $\mu_0$,$\mu_0+z_{1-{\frac\alpha2}}\frac\sigma{\sqrt n}$},
      ytick=\empty,
      enlargelimits=false, clip=false, axis on top,
      grid = major]
      \addplot [fill=cyan!20, draw=none, domain=-5:-1.96]
               {gauss(-0,1)} \closedcycle;
      \addplot [fill=cyan!20, draw=none, domain=1.96:5]
               {gauss(-0,1)} \closedcycle;
      \addplot [very thick,cyan!50!black] {gauss(-0,1)};
    \end{axis}
  \end{tikzpicture}

  \bigskip$H_1$\bigskip

  \begin{tikzpicture}
    \begin{axis}
      [no markers, domain=-5:5, samples=100,
      axis lines*=left, xlabel=$\bar X$, ylabel=$ $,
      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=20ex, width=\textwidth,
      xtick={-1.96,-1,0,1.645},
      xticklabels={$\mu_0{-}z\frac\sigma{\sqrt n}$,$\mu$,
        $\mu_0$,$\mu_0+z_{1-{\frac\alpha2}}\frac\sigma{\sqrt n}$},
      ytick=\empty,
      enlargelimits=false, clip=false, axis on top,
      grid = major]
      \addplot [fill=cyan!20, draw=none, domain=-5:-1.96]
               {gauss(-1,1)} \closedcycle;
      \addplot [fill=cyan!20, draw=none, domain=1.96:5]
               {gauss(-1,1)} \closedcycle;
      \addplot [very thick,cyan!50!black] {gauss(-1,1)};
    \end{axis}
  \end{tikzpicture}
  
  $\varphi'$
  
  \bigskip$H_0$\bigskip

  \begin{tikzpicture}
    \begin{axis}
      [no markers, domain=-5:5, samples=100,
      axis lines*=left, xlabel=$\bar X$, ylabel=$ $,
      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=20ex, width=\textwidth,
      xtick={-0,0,1.645}, xticklabels={$$,$\mu_0$,
    $\mu_0+z_{1-{\alpha}}\frac\sigma{\sqrt n}$},
      ytick=\empty,
      enlargelimits=false, clip=false, axis on top,
      grid = major]
      \addplot [fill=cyan!20, draw=none, domain=1.645:5]
               {gauss(-0,1)} \closedcycle;
      \addplot [very thick,cyan!50!black] {gauss(-0,1)};
    \end{axis}
  \end{tikzpicture}

  \bigskip$H_1$\bigskip

  \begin{tikzpicture}
    \begin{axis}
      [no markers, domain=-5:5, samples=100,
      axis lines*=left, xlabel=$\bar X$, ylabel=$ $,
      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=20ex, width=\textwidth,
      xtick={-1,0,1.645}, xticklabels={$\mu$,$\mu_0$,
        $\mu_0+z_{1-{\alpha}}\frac\sigma{\sqrt n}$},
      ytick=\empty,
      enlargelimits=false, clip=false, axis on top,
      grid = major]
      \addplot [fill=cyan!20, draw=none, domain=1.645:5]
               {gauss(-1,1)} \closedcycle;
      \addplot [very thick,cyan!50!black] {gauss(-1,1)};
    \end{axis}
  \end{tikzpicture}
\end{ejemplo}
\end{document}
