DISTRIBUCIONES CONTINUAS DE PROBABILIDAD

DISTRIBUCION UNIFORME

Parámetros

min <- 5
max <- 10

Generación de aleatorios uniformes:

u <- runif(10000, min, max)
head(u)
## [1] 8.104 8.714 5.493 6.509 9.461 7.360
dunif(7, min, max)
## [1] 0.2
punif(8, min, max)
## [1] 0.6
qunif(0.9, min, max)
## [1] 9.5
curve(dunif(x, 5, 10), from = min - 0.5, to = max + 0.5, lwd = 2, main = expression(f(x) == 
    frac(1, 5)))

plot of chunk unnamed-chunk-2

mean(u)
## [1] 7.5
sd(u)
## [1] 1.442
hist(u, freq = FALSE, main = "Histograma de aleatorios uniformes u", ylab = "Densidad", 
    col = "blue")

plot of chunk unnamed-chunk-2

DISTRIBUCION EXPONENCIAL

Parámetro

l <- 2

Generación de aleatorios

ex <- rexp(10000, l)
head(ex)
## [1] 0.15605 0.07427 0.16934 0.65097 0.17603 0.22679
dexp(1.5, l)
## [1] 0.09957
pexp(2.2, l)
## [1] 0.9877
qexp(0.8)
## [1] 1.609
curve(dexp(x, l), from = -1, to = 4, lwd = 2, col = "green", main = expression(f(x) == 
    2 * e^(-2 * x)))

plot of chunk unnamed-chunk-4

mean(ex)
## [1] 0.4973
sd(ex)
## [1] 0.5035
hist(ex, freq = FALSE, main = "Histograma de ex", col = "yellow")

plot of chunk unnamed-chunk-4

DISTRIBUCION NORMAL

Parámetros

media <- 2
desv <- 7
normales <- rnorm(10000, media, desv)
head(normales)
## [1]  7.4433  4.1331 -0.6274  0.9905  1.2648  2.0581
dnorm(1.5, media, desv)
## [1] 0.05685
pnorm(2.2, media, desv)
## [1] 0.5114
qnorm(0.8, media, desv)
## [1] 7.891
curve(dnorm(x, media, desv), from = media - 4 * desv, to = media + 4 * desv, 
    lwd = 2, col = "yellow", main = expression(paste(frac(1, sigma * sqrt(2 * 
        pi)), " ", plain(e)^{
        frac(-(x - mu)^2, 2 * sigma^2)
    })), cex = 1.2)

plot of chunk unnamed-chunk-5

mean(normales)
## [1] 2.013
sd(normales)
## [1] 6.933
hist(normales, freq = FALSE, main = "Histograma de aleatorios normales", ylab = "Densidad", 
    col = "gray")

plot of chunk unnamed-chunk-5

FUNCION GAMMA

gamma(1)
## [1] 1
gamma(0.5)
## [1] 1.772
sqrt(pi)
## [1] 1.772
gamma(11) == factorial(10)
## [1] TRUE
curve(gamma(x), from = 0.1, to = 4, col = "violet", lwd = 3, main = expression(Gamma(x) == 
    integral(t^(x - 1) * plain(e)^-t * dt, 0, infinity)))

plot of chunk unnamed-chunk-6

DISTRIBUCION GAMMA

Parámetros

l <- 2
r <- 3

Generación de aleatorios

ga <- rgamma(10000, l, r)
dgamma(1.5, l, r)
## [1] 0.15
pgamma(2.2, l, r)
## [1] 0.9897
qgamma(0.5, l, r)
## [1] 0.5594
curve(dgamma(x, l, r), from = -0.5, to = 3, lwd = 3, main = expression(f(x) == 
    frac(lambda^r, Gamma(r)) * x^(r - 1) * plain(e)^-(lambda * x)))

plot of chunk unnamed-chunk-8

mean(ga)
## [1] 0.67
sd(ga)
## [1] 0.4763
hist(ga, freq = FALSE, main = "Histograma de aleatorios gamma ", ylab = "Densidad", 
    col = "green")

plot of chunk unnamed-chunk-8

DISTRIBUCION CHI-CUADRADO

Parámetro

v <- 3

Generación de aleatorios

ji <- rchisq(10000, l, r)
dchisq(1.5, v)
## [1] 0.2308
pchisq(2.2, v)
## [1] 0.4681
qchisq(0.01, v)
## [1] 0.1148
curve(dchisq(x, v), from = -0.5, to = 20, lwd = 3, main = expression(f(x) == 
    frac(1, 2^(frac(v, 2)) * Gamma(frac(v, 2))) * x^(frac(v, 2) - 1) * plain(e)^(-frac(x, 
        2))))

plot of chunk unnamed-chunk-10

mean(ji)
## [1] 5.052
sd(ji)
## [1] 4.022
hist(ji, freq = FALSE, main = "Histograma de aleatorios chi-cuadrado", ylab = "Densidad", 
    col = "red")

plot of chunk unnamed-chunk-10

DISTRIBUCION t DE STUDENT

v grados de libertad

v <- 3

Generación de aleatorios

tds <- rt(1000, v)
head(tds)
## [1] -0.5627  0.8447  0.2205 -1.0093  1.6758 -1.3754
dt(-1.5, v)
## [1] 0.12
pt(2.2, v)
## [1] 0.9424
qt(0.9, v)
## [1] 1.638
dt(1.5, v)
## [1] 0.12
pt(-2.2, v)
## [1] 0.05759
qt(0.1, v)
## [1] -1.638
curve(dt(x, v), from = -4, to = 4, lwd = 3, col = "blue", main = expression(f(x) == 
    frac(Gamma(frac(v + 1, 2)), sqrt(v * pi) * Gamma(frac(v, 2))) * (1 + frac(x^2, 
        v))^(-frac(v + 1, 2))))

plot of chunk unnamed-chunk-12

mean(tds)
## [1] 0.02897
sd(tds)
## [1] 1.614
hist(tds, xlim = c(-4.5, 4.5), freq = FALSE, breaks = 50, main = "Histograma de aleatorios t de Student tds", 
    ylab = "Densidad", col = "blue")

plot of chunk unnamed-chunk-12