Notación

\[ X{\sim}\chi_{(n)}^2 \]

Nota: La suma de variables aleatorias normales o distribuidas de forma normal o Gaussiana, elevadas al cuadrado sigue o tiene una distribución ji o chi cuadrado; con grados de libertad igual al número de variables aleatorias sumadas

\[ \text{Si }X_1,X_2,\ldots,X_n\stackrel{iid}{\sim}N(\mu_x,\sigma_x^2)\text{ entonces }X=\sum_{i=1}^{n}X_i^2{\sim}\chi_{(n)}^2 \]

Parámetros

\[ E(X)=n \]

\[ Var(X)=2n \]

donde \(n\) el número de variables aleatorias normales elevadas al cuadrado que son sumadas.

Nota: \(df\) los grados de libertad de la distribución son iguales al número de variables sumadas \(n\)

Simulación, deducción y ejercicios

library(ggfortify)
## Loading required package: ggplot2
chicuadrado <- function(df,fill="gray",colour="black",p=NULL){
  ggdistribution(
    func=dchisq,
    x=seq(
      from=0,
      to=9*sqrt(2*df),
      by=0.01
    ),
    df=df,
    fill=fill,
    colour=colour,
    p=p
  )
}
chicuadrado(df=3,
            p=chicuadrado(df=17,
                          fill="red",
                          colour="orange",
                          p=chicuadrado(df=31,
                                        fill="yellow",
                                        colour="green")))

Construcción de la variable aleatoria

jicuadrado <- function(n,df,fill="orange",color="red"){
  chicuadradosimulada <- replicate(n=n,expr=sum(rnorm(df)**2))
  valoresenx <- seq(from=0,to=max(chicuadradosimulada),by=0.01)
  densidadchicuadrado <- dchisq(x=valoresenx,df=df)
  chicuadradoteorica <- data.frame(x=valoresenx,y=densidadchicuadrado)
  ggplot() + 
    geom_histogram(
      mapping=aes(
        x=chicuadradosimulada,
        y=after_stat(density),
      ),
      bins=round(x=sqrt(x=n),digits=0),
      fill=fill,
      color=color
    ) + 
    geom_line(
      data=chicuadradoteorica,
      mapping=aes(x=x,y=y),
      color="black",
      alpha=0.7,
      linewidth=2
    )
}
jicuadrado(n=10000,df=3)

jicuadrado(n=10000,df=17,fill="yellow",color="green")

jicuadrado(n=10000,df=31,fill="blue",color="purple")

Cálculo de probabilidades

  • \(P_{\chi_{(3)}^2}(X=1)\)
densidad.chicuadrado <- function(x,df){
  ggdistribution(
    func=dchisq,
    x=seq(
      from=0,
      to=9*sqrt(2*df),
      by=0.01
    ),
    df=df,
    colour="blue",
    p=ggdistribution(
      func=dchisq,
      x=seq(
        from=x-0.05,
        to=x+0.05,
        by=0.01
      ),
      df=df,
      fill="blue",
      colour="blue"
    )
  )
}
densidad.chicuadrado(x=1,df=3)

dchisq(x=1,df=3)
## [1] 0.2419707
  • \(P_{\chi_{(17)}^2}(X{\leq}13)\)
distribucion.chicuadrado <- function(q,df,lower.tail=TRUE){
  ggdistribution(
    func=dchisq,
    x=seq(
      from=0,
      to=9*sqrt(2*df),
      by=0.01
    ),
    df=df,
    colour="blue",
    p=ggdistribution(
      func=dchisq,
      x=if(lower.tail==TRUE){
        seq(
          from=0,
          to=q,
          by=0.01
        )
      } else {
        seq(
          from=q,
          to=9*sqrt(2*df),
          by=0.01
        )
      },
      df=df,
      fill="blue",
      colour="blue"
    )
  )
}
distribucion.chicuadrado(q=13,df=17)

pchisq(q=13,df=17)
## [1] 0.263814
distribucion.chicuadrado(q=13,df=17,lower.tail=FALSE)

pchisq(q=13,df=17,lower.tail=FALSE)
## [1] 0.736186
  • \(P_{\chi_{(31)}^2}(26{\leq}X{\leq}35)\)
probabilidad.chicuadrado <- function(a,b,df){
  ggdistribution(
    func=dchisq,
    x=seq(
      from=0,
      to=9*sqrt(2*df),
      by=0.01
    ),
    df = df,
    colour = "blue",
    p = ggdistribution(
      func=dchisq,
      x=seq(
        from=a,
        to=b,
        by=0.01
      ),
      df = df,
      colour ="blue",
      fill = "blue"
    )
  )
}
probabilidad.chicuadrado(a=26,b=35,df=31)

pchisq(q=35,df=31)-pchisq(q=26,df=31)
## [1] 0.4375226

Tarea