Skip to content

Instantly share code, notes, and snippets.

@Athospd
Created February 25, 2015 00:38
Show Gist options
  • Save Athospd/4255b35217b7d751910a to your computer and use it in GitHub Desktop.
Save Athospd/4255b35217b7d751910a to your computer and use it in GitHub Desktop.
desenha uma matriz de distribuições beta com diferentes parâmetros em ggplot2
# matriz de betas!
library(ggplot2)
library(dplyr)
# parâmetros da beta
a <- b <- c(0.1,0.5,1,2,3)
# pontos pra fazer a linha
x <- seq(0, 1, len = 100)
# bd gambi
df <- expand.grid(a = a, b = b, x = x) %>%
mutate(densidade = dbeta(x, a, b))
# ggplot semi coxinhado
ggplot(df) +
geom_line(aes(x = x, y = densidade, colour = (a*b/((a+b)^2*(a+b+1))))) +
facet_grid(a ~ b) +
scale_colour_gradient2(low = "royalblue", high = "salmon2", mid = "orange", midpoint = 0.1)
labs(colour = "Variância")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment