Skip to content

Instantly share code, notes, and snippets.

@deanmarchiori
Created July 15, 2019 03:42
Show Gist options
  • Save deanmarchiori/10a1485f2254bc59e06eb457579f854b to your computer and use it in GitHub Desktop.
Save deanmarchiori/10a1485f2254bc59e06eb457579f854b to your computer and use it in GitHub Desktop.
Easy Beta distribution plots in base R - auto scaling axes
beta_plot <- function(shape_1 = 1, shape_2 = 1,
x_min = qbeta(0.0001, shape_1, shape_2),
x_max = qbeta(0.9999, shape_1, shape_2)){
x <- seq(x_min, x_max, length.out = 1000)
y <- dbeta(x, shape_1, shape_2)
plot(x, y,
type = "l",
ylab = "density",
xlab = "probability",
main = paste0("Beta(", shape_1, ", ", shape_2, ")"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment