Skip to content

Instantly share code, notes, and snippets.

@rmcelreath
Created April 26, 2017 16:45
Show Gist options
  • Save rmcelreath/5e2a58a49b027e17640545675ee634c1 to your computer and use it in GitHub Desktop.
Save rmcelreath/5e2a58a49b027e17640545675ee634c1 to your computer and use it in GitHub Desktop.
Example of using shade to paint tail on distribution
library(rethinking)
p_grid <- seq( from=0 , to=1 , length.out=100 )
prior <- rep( 1 , 100 )
likelihood <- dbinom( 6 , size=9 , prob=p_grid )
posterior <- likelihood * prior
posterior <- posterior / sum(posterior)
plot( posterior ~ p_grid , type="l" )
shade( posterior ~ p_grid , lim=c(0,0.5) , col=rangi2 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment