unif function

Nice Uniform Points in Interval

Nice Uniform Points in Interval

Give regularly spaced points on interval [c,c][-c,c] with mean 0 (exactly) and variance about 1 (very close for even n

and larger round.dig). Note that cc depends on n.

unif(n, round.dig = 1 + trunc(log10(n)))

Arguments

  • n: positive integer specifying the number of points desired.
  • round.dig: integer indicating to how many digits the result is rounded.

Returns

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)/12Var(1,2,...,n) = n(n+1)/12.

Author(s)

Martin Maechler, ca 1990

See Also

runif for producing uniform random numbers.

Examples

(u <- unif(8)) var(u) (u. <- unif(8, 12))# more digits in result, hence precision for Var : var(u.)
  • Maintainer: Martin Maechler
  • License: GPL (>= 2)
  • Last published: 2024-11-05