meanint_data {exams.forge} | R Documentation |
Integer Observations and Mean
Description
The meanint_data
function generates a set of integer observations with a specified integer mean.
It takes the number of observations or x
values and an optional range parameter, r
, that defines the permissible range
of x values (defaulting to the range of x
). Additional parameters are passed to the mean
function.
The function employs a iterative process, adjusting individual observations to achieve an integer mean.
It uses a random selection approach, modifying a randomly chosen observation and checking if the resulting mean is closer to an integer.
The process continues until the mean becomes an integer.
Usage
meanint_data(x, r = range(x), ...)
Arguments
x |
numeric: number of observations or x values |
r |
numeric: the range in which the x values allowed (default: |
... |
further parameters given to |
Value
A set of integer observations with an integer mean.
Examples
x <- meanint_data(10, c(1, 10))
mean(x)