library(ggplot2)
library(gridExtra)
ensayos <- 100
probabilidad.de.contagio <- 0.20
valores.posibles <- 0:ensayos
fx.geometrica <- dgeom(x = valores.posibles, prob = probabilidad.de.contagio)
fbg = pgeom(q = valores.posibles, prob = probabilidad.de.contagio, lower.tail = TRUE)
fx.geometrica = data.frame(x = valores.posibles, "f(X)" = fx.geometrica, "F(X)" = fbg)
#head(fx.geometrica)
library(ggplot2)
p3 <- ggplot(fx.geometrica, aes(x = x, y = f.X.)) +
  geom_bar(aes(color = x), stat = "identity", fill = "white") + theme(legend.position = "none") + xlab("") + ylab("Densidad f(x)")
library(ggplot2)
p4 <- ggplot(fx.geometrica, aes(x = x, y = F.X.)) +
  geom_bar(aes(color = x), stat = "identity", fill = "white") + theme(legend.position = "none") + xlab("") + ylab("Distribución F(x)")
library(gridExtra)
grid.arrange(p3, p4, nrow = 2, top = "Distribución geométrica")