Paquetes requeridos: TeachingDemos
library(TeachingDemos)
-distribucion continua mas importante
-curva tiene forma de campana (campana de Gauss=asintotica, simetrica con respecto al promedio)
-determinada por: media y sd
-media, mediana y moda son iguales
-68%
ejemplos:
media=0
sd=1
x=exactamente 2
dnorm(2,0,1)
## [1] 0.05399097
dnorm= no se acumula
pnorm(2,0,1)
## [1] 0.9772499
pnorm= si se acumula, se calcula el valor de probabilidad
1-pnorm(2,0,1)
## [1] 0.02275013
1-pnorm= se calcula el valor de probabilidad restante
-areas de rechazo al 95% de confianza= 1.96
P(0 ≤ Z ≤ 1.35)
pnorm(1.35)-pnorm(0)
## [1] 0.411492
P(Z ≤ 1)
pnorm(1)
## [1] 0.8413447
La función dnorm() nos brinda los valores de probabilidad de la función de densidad.
La función pnorm() calcula la probabilidad acumulada, siendo esta el área bajo la curva hasta una ordenada (eje x) especifica.
ejemplos:
pnorm(2.60)-pnorm(-1.73)
## [1] 0.9535237
1-pnorm(2.65)
## [1] 0.004024589
z.test(x=60,mu=63,sd=4.4, alternative = "two.sided")
##
## One Sample z-test
##
## data: 60
## z = -0.68182, n = 1.0, Std. Dev. = 4.4, Std. Dev. of the sample
## mean = 4.4, p-value = 0.4954
## alternative hypothesis: true mean is not equal to 63
## 95 percent confidence interval:
## 51.37616 68.62384
## sample estimates:
## mean of 60
## 60
o
pnorm(60,63,4.4)*2
## [1] 0.4953539
** cuando la pregunta es menor a la media= se multiplica por 2
** cuando la pregunta es mayor a la media= (1-pnorm(x))*2
(1-pnorm(67,63,4.4))*2
## [1] 0.3633021
o
z.test(67,63,4.4)
##
## One Sample z-test
##
## data: 67
## z = 0.90909, n = 1.0, Std. Dev. = 4.4, Std. Dev. of the sample
## mean = 4.4, p-value = 0.3633
## alternative hypothesis: true mean is not equal to 63
## 95 percent confidence interval:
## 58.37616 75.62384
## sample estimates:
## mean of 67
## 67
5)Determine la probabilidad de encontrar arboles con DAP mayores a 70 cm, dentro de la población
z.test(70,63,4.4,alternative="greater")
##
## One Sample z-test
##
## data: 70
## z = 1.5909, n = 1.0, Std. Dev. = 4.4, Std. Dev. of the sample mean
## = 4.4, p-value = 0.05582
## alternative hypothesis: true mean is greater than 63
## 95 percent confidence interval:
## 62.76264 Inf
## sample estimates:
## mean of 70
## 70
o
1-pnorm(70,63,4.4)
## [1] 0.05581502
qnorm(0.05581502, lower.tail = FALSE)
## [1] 1.590909
** solo en funciones acumuladas
** siempre usar lower.tail=FALSE
z.test(55,63,4.4, alternative="g")
##
## One Sample z-test
##
## data: 55
## z = -1.8182, n = 1.0, Std. Dev. = 4.4, Std. Dev. of the sample
## mean = 4.4, p-value = 0.9655
## alternative hypothesis: true mean is greater than 63
## 95 percent confidence interval:
## 47.76264 Inf
## sample estimates:
## mean of 55
## 55
o
1-pnorm(-1.8182)
## [1] 0.9654832
ra<-c(8.08,6.33,7.88,10.98,7.81,6.49,9.67,9.17,9.06,9.77,8.89,6.06,7.86,6.86,11.79,4.88,10.42,4.98,6.25,7.04,7.76,5.33,4.98,7,8.74,7.14,6.73,7.79,9.48,8.86,6.29,9.73,9,5.39,7.56)
ra
## [1] 8.08 6.33 7.88 10.98 7.81 6.49 9.67 9.17 9.06 9.77 8.89
## [12] 6.06 7.86 6.86 11.79 4.88 10.42 4.98 6.25 7.04 7.76 5.33
## [23] 4.98 7.00 8.74 7.14 6.73 7.79 9.48 8.86 6.29 9.73 9.00
## [34] 5.39 7.56
mean(ra)
## [1] 7.772857
sd(ra)
## [1] 1.771116
z.test(7.5,7.7,1.77, conf.level=.95)
##
## One Sample z-test
##
## data: 7.5
## z = -0.11299, n = 1.00, Std. Dev. = 1.77, Std. Dev. of the sample
## mean = 1.77, p-value = 0.91
## alternative hypothesis: true mean is not equal to 7.7
## 95 percent confidence interval:
## 4.030864 10.969136
## sample estimates:
## mean of 7.5
## 7.5
o
pnorm (7.5,mean(ra),sd(ra))*2
## [1] 0.8775628