powered by
Rounds a vector such that the sum of 1 is preserved. Rounds a matrix such that the rows still sum up to 1.
round_stochastic(x, digits = 3)
a stochastic vector or a row-stochastic matrix.
number of digits for rounding.
The rounded vector or matrix.
Rounds and adjusts one entry such that the rounding error is the smallest.
round
# NOT RUN { x <- c(0.25, 0.25, 0.5) round_stochastic(x, 2) round_stochastic(x, 1) round_stochastic(x, 0) # }
Run the code above in your browser using DataLab