Give regularly spaced points on interval \([-c,c]\) with mean 0
(exactly) and variance about 1 (very close for even n
and larger round.dig). Note that \(c\) depends on n.
Arguments
- n
positive integer specifying the number of points desired.
- round.dig
integer indicating to how many digits the result is
rounded.
Value
numeric vector of length n, symmetric around 0, hence
with exact mean 0, and variance approximately 1.
Note
It relies on the fact that \(Var(1,2,...,n) = n(n+1)/12\).
Author
Martin Maechler, ca 1990
See also
runif for producing uniform random numbers.
Examples
(u <- unif(8))
#> [1] -1.4 -1.0 -0.6 -0.2 0.2 0.6 1.0 1.4
var(u)
#> [1] 0.96
(u. <- unif(8, 12))# more digits in result, hence precision for Var :
#> [1] -1.429 -1.021 -0.612 -0.204 0.204 0.612 1.021 1.429
var(u.)
#> [1] 1