Learn R Programming

pomdp (version 1.0.2)

round_stochastic: Round a stochastic vector or a row-stochastic matrix

Description

Rounds a vector such that the sum of 1 is preserved. Rounds a matrix such that the rows still sum up to 1.

Usage

round_stochastic(x, digits = 3)

Arguments

x

a stochastic vector or a row-stochastic matrix.

digits

number of digits for rounding.

Value

The rounded vector or matrix.

Details

Rounds and adjusts one entry such that the rounding error is the smallest.

See Also

round

Examples

Run this code
# 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