`rbnorm()`

is a function to randomly generate values from a bounded normal
(really: a scaled beta) distribution with specified mean, standard deviation, and upper/lower bounds.
I use this function to randomly generate data that we treat as interval for sake of getting
means and standard deviations, but have discernible bounds (and even skew) to teach students
about things like random sampling and central limit theorem.

rbnorm(n, mean, sd, lowerbound, upperbound, round = FALSE, seed)

n | the number of observations to simulate |
---|---|

mean | a mean to approximate |

sd | a standard deviation to approximate |

lowerbound | a lower bound for the data to be generated |

upperbound | an upper bound for the data to be generated |

round | whether to round the values to whole integers. Defaults to FALSE |

seed | set an optional seed |

The function returns a vector of simulated data approximating the user-specified conditions.

I call it "bounded normal" when it's really a beta distribution. I'm aware of this. I took much of this code from somewhere. I forget where.

#> # A tibble: 10,000 x 1 #> x #> <dbl> #> 1 51.3 #> 2 75.9 #> 3 57.1 #> 4 66.4 #> 5 34.2 #> 6 71.4 #> 7 29.8 #> 8 42.5 #> 9 66.2 #> 10 56.2 #> # … with 9,990 more rows#> # A tibble: 10,000 x 1 #> x #> <dbl> #> 1 58 #> 2 27 #> 3 56 #> 4 53 #> 5 49 #> 6 80 #> 7 47 #> 8 74 #> 9 61 #> 10 76 #> # … with 9,990 more rows#> # A tibble: 10,000 x 1 #> x #> <dbl> #> 1 72.8 #> 2 44.6 #> 3 66.9 #> 4 38.4 #> 5 39.8 #> 6 56.5 #> 7 45.5 #> 8 47.3 #> 9 41.4 #> 10 39.2 #> # … with 9,990 more rows