Randomly Round A Vector of Integers to Base 3
Apply the 'Random Round to Base 3' (RR3) algorithm to a vector of integers (or doubles where round(x) == x
.
rr3(x)
x
: A vector of integers (in the sense that round(x) == x
.) Can be an rvec .A randomly-rounded version of x
.
The RR3 algorithm is used by statistical agencies to confidentialize data. Under the RR3 algorithm, an integer
is randomly rounded as follows:
RR3 has some nice properties:
The randomly-rounded version of
has expected value .
If non-negative, then the randomly rounded version of is non-negative.
If is non-positive, then the randomly rounded version of is non-positive.
x <- c(1, 5, 2, 0, -1, 3, NA) rr3(x)
Useful links