Created
October 16, 2017 13:35
-
-
Save jmunozal/f0588886cdf02703e4e6dcf6e86370a7 to your computer and use it in GitHub Desktop.
Central Limit Theorem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setwd("/Users/kepler/Dropbox/Classroom/UOC - Master Bioinformatica/Software para el Análisis de Datos/PACS/PAC2") | |
#A. Generación de valores aleatorios | |
valores <- runif(100000, min = 1, max = 5) | |
#B. Agrupación en 20 columnas | |
matriz <- matrix(valores, ncol = 20) | |
# histogramas | |
jpeg("histogramas.jpg") | |
par(mfrow = c(3,2)) | |
hist(matriz[,1], main = "Histograma columna 1", xlab = "x", ylab = "N") | |
hist(matriz[,2], main = "Histograma columna 2", xlab = "x", ylab = "N") | |
hist(matriz[,3], main = "Histograma columna 3", xlab = "x", ylab = "N") | |
hist(matriz[,4], main = "Histograma columna 4", xlab = "x", ylab = "N") | |
hist(matriz[,5], main = "Histograma columna 5", xlab = "x", ylab = "N") | |
dev.off() | |
#C.Suma de valores por fila y generación de histograma | |
vectorSuma <- NULL | |
for (x in 1:nrow(matriz)) { | |
vectorSuma[x] <- sum(matriz[x,]) | |
} | |
jpeg("histograma_suma.jpg") | |
hist(vectorSuma, main = "Histograma suma", xlab = "suma", ylab = "N") | |
dev.off() | |
jpeg("qq.jpg") | |
qqnorm(vectorSuma) | |
qqline(vectorSuma) | |
dev.off() | |
# Ajuste a curva normal | |
hist(vectorSuma, main = "Ajuste a curva normal", xlab = "suma", ylab = "N", probability = T) | |
curve(dnorm(x, 60, 5.164), from = 40, col="red", to = 80, add=T) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment