Learn R Programming

npsf (version 0.8.0)

halton: 'halton' method for class 'npsf'

Description

Provides Halton draws, deviates from a uniform distribution.

Usage

halton(n = 1, n.bases = 1, bases = NULL, 
                   start = 0, random.primes = FALSE, seed = 7, 
                   scale.coverage = FALSE, shuffle = FALSE)

Arguments

n

number of prime numbers to be returned (the row number in the value).

n.bases

numeric. number of bases used. (the column number in the value).

bases

numeric. Supply specific order numbers for getting primes, see primes. See examples.

start

numeric. from which value in the halton sequence to start. Default is 0, which is actually 0.

random.primes

logical. if TRUE, the n.bases primes are chosen on a random basis from 100008 available prime numbers. See primes.

seed

set seed for replicability. Default is 17345168.

scale.coverage

logical. at larger primes not whole [0,1] interval is covered. if TRUE, rescale is used to fill the coverage.

shuffle

logical. if TRUE, each column in the value is randomly reshuffled (seed is used).

Value

halton returns Halton draws.

See Also

sf and primes.

Examples

Run this code
# NOT RUN {
  require( npsf )
  
  # obtain first 10 x 7 matrix with the first 7 primes as bases
  npsf::halton(10, n.bases = 7)
  
  # obtain first 10 x 7 matrix with the randomly chosen 7 primes as bases
  npsf::halton(10, n.bases = 7, random.primes = TRUE, seed = 17345168)
  
  # just one column with desired prime
  npsf::halton(10, bases = 1)
  
  # or 2 columns
  npsf::halton(10, bases = c(1,7))
  
  # if bases are large
  npsf::halton(10, bases = c(1,7)*1000)
  
  # the coverage is not great
  npsf::halton(10, bases = c(1,7)*1000, scale.coverage = TRUE)
  
  # reshuffle them, use seed for replicability
  npsf::halton(10, bases = c(1,7)*1000, scale.coverage = TRUE, shuffle = TRUE, seed = 17345168)
  
# }

Run the code above in your browser using DataLab