p.round: p.round

Description Usage Arguments Details Value Author(s)

View source: R/Utility.R

Description

p.round performs stochastic or probabilistic rounding of non-integer values.

Usage

1
p.round(x = NULL, q = NA)

Arguments

x

Required Default = none

q

Optional Default = none

Details

The input "x" is a vector of values to be rounded. Each value of x is rounded independently, either up or down. The fractional value of x is used to determine weights for rounding in each direction. For example, if x=4.3, then it is rounded up to 5 with probability 0.3, else rounded down to 4 (with probability 0.7). The p.round function always returns integer values, and does not introduce bias. In the above example, if the argument were 4.3 a large number of times, then the returned values (all either 4 or 5) would average 4.3 with a small residual error which approaches zero as "n" gets large.

Value

A vector of the same length as the input "x", containing all integer values.

Author(s)

Kristin Isaacs, Graham Glen


HumanExposure/SHEDSDevel documentation built on Oct. 30, 2019, 6:49 p.m.