rbnorm: Bounded Normal (Really: Scaled Beta) Distribution In stevemisc: Steve's Miscellaneous Functions

 rbnorm R Documentation

Bounded Normal (Really: Scaled Beta) Distribution

Description

`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.

Usage

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

Arguments

 `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

Details

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.

Value

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

Examples

```
library(tibble)

tibble(x = rbnorm(10000, 57, 14, 0, 100))
tibble(x = rbnorm(10000, 57, 14, 0, 100, round = TRUE))
tibble(x = rbnorm(10000, 57, 14, 0, 100, seed = 8675309))
```

stevemisc documentation built on April 12, 2022, 5:06 p.m.