Skip to content

Instantly share code, notes, and snippets.

@statwonk
Created June 2, 2019 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save statwonk/ececfe9263cf126d7281872ed81ba040 to your computer and use it in GitHub Desktop.
Save statwonk/ececfe9263cf126d7281872ed81ba040 to your computer and use it in GitHub Desktop.
A visualization of the beta distribution.
library(tidyverse)
plot.new()
par(bg = "black")
plot(density(rbeta(1e6, 50, 50)), col = "pink3", lwd = 1, ylim = c(0, 8),
xlab = "", ylab = "", main = "Beta distribution", axes = FALSE,
col.main = 'white')
map2(c(seq(1, 49, 1), 50),
c(seq(1, 49, 1), 50),
function(x, y){ message(x,y);rbeta(1e6, x + 1, y + 1)}) %>%
map(function(x) { density(x) %>%
lines(col = sample(colors(), 1),
lwd = 1,
lty = sample(1:10, 1))}) %>%
invisible()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment