R/plot_distributions.R

Defines functions plot_gamma plot_uniform

plot_gamma <- function(n, shape, rate, lab) {

  df <- data.frame(x = seq(0, 10, length.out = 1000))
  # df <- data.frame(x = rgamma(n, shape = shape, rate = rate))

  ggplot(data = df, aes(x = x)) +
    stat_function(fun = dgamma,
                  args = list(shape = shape, rate = rate),
                  size = 1) +
    scale_x_continuous(NULL) +
    scale_y_continuous("PDF") +
    ggtitle(lab) +
    theme_bw()

}

plot_uniform <- function(n, min, max, lab) {

  df <- data.frame(x = runif(n, min = min, max = max))

  ggplot(data = df, aes(x = x)) +
    stat_function(fun = dunif,
                  args = list(min = min, max = max),
                  size = 1) +
    scale_x_continuous(NULL) +
    scale_y_continuous("PDF") +
    ggtitle(lab) +
    theme_bw()

}
lorecatta/DENVclimate documentation built on Dec. 11, 2019, 7:05 a.m.