Last active
September 29, 2015 21:02
-
-
Save fdavidcl/2ed9d74cc09958234d3c to your computer and use it in GitHub Desktop.
Teorema Central del Límite: lanzando dados
This file contains 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
# Guion para comprobación del Teorema Central del Límite: | |
# | |
# The central limit theorem (CLT) states that, given certain conditions, | |
# the arithmetic mean of a sufficiently large number of iterates of | |
# independent random variables, each with a well-defined expected value | |
# and well-defined variance, will be approximately normally distributed, | |
# regardless of the underlying distribution -- Wikipedia (https://en.wikipedia.org/wiki/Central_limit_theorem) | |
# | |
simular <- function(dados = 20, caras = 6, muestras = 1000) { | |
throwDice <- function(n) | |
sum(sample(1:caras, n, replace = TRUE)) | |
diceNum <- rep(dados, muestras) | |
hist(sapply(diceNum, throwDice), breaks = 100) | |
} | |
# Ejemplos: | |
simular() | |
simular(100, 20, 100000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment