Calcular y dibujar el intervalo de Chebyshev con R-Project

Calcular y dibujar el intervalo de Chebyshev con R-Project de las distrbuciones continuas Logaritmo-Normal, LN(1 , 0'5) y LN(1 , 0'2).  Instalamos el paquete "distr" y "distrEx" en el R-Project.



Programa en R:


> library(distr)
> library(distrEx)
> X<- Lnorm(1,0.2)
> intervalo<-c(E(X)-sqrt(2*sqrt(var(X))),E(X)+sqrt(2*sqrt(var(X))))
> intervalo
[1] 1.714675 3.831714
> X2<- Lnorm(1,0.5)
> intervalo2<-c(E(X2)-sqrt(2*sqrt(var(X2))),E(X2)+sqrt(2*sqrt(var(X2))))
> intervalo2
[1] 1.268272 4.892162
> par(mfrow=c(2,1))
> cord.x <- c(intervalo[1],seq(intervalo[1],intervalo[2],0.01),intervalo[2])
> cord.y <- c(0,d(X)(seq(intervalo[1],intervalo[2],0.01)),0)
> curve(dlnorm(x,meanlog =1, sdlog =0.2), 1, 5)
> polygon(cord.x,cord.y,col='red')
> cord.x <- c(intervalo2[1],seq(intervalo2[1],intervalo2[2],0.01),intervalo2[2])
> cord.y <- c(0,d(X2)(seq(intervalo2[1],intervalo2[2],0.01)),0)
> curve(dlnorm(x,meanlog =1, sdlog =0.5), 0, 6)
> polygon(cord.x,cord.y,col='skyblue')


No hay comentarios: