rnormlim | R Documentation |
Generates random numbers from a normal distribution with specified mean and standard deviation, constrained between minimum and maximum values. Any values outside the specified range are resampled until they fall within the limits.
rnormlim(n, mu = 0, sigma = 1, min = -Inf, max = Inf)
n |
Number of observations to generate |
mu |
Mean of the normal distribution (default = 0) |
sigma |
Standard deviation of the normal distribution (default = 1) |
min |
Minimum allowed value (default = -Inf) |
max |
Maximum allowed value (default = Inf) |
A numeric vector of length n containing random normal values constrained between min and max
# Generate 1000 standard normal values between -2 and 2
x <- rnormlim(1000, mu = 0, sigma = 1, min = -2, max = 2)
# Generate 500 normal values with mean 10, sd 2, minimum 5
y <- rnormlim(500, mu = 10, sigma = 2, min = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.