Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Halton

Halton's quasi-random numbers


Description

Generating quasi-random numbers by Halton's radical inversion algorithm.

Usage

HS247(K,N,R,P=rep(0,K))

Arguments

K

Integer, number of random sequences

N

Integer, length of the random sequences

R

Integer 1..K, roots of inversion, should be prime

P

Integer 1..K, starting points of inversion

Value

A matrix of K columns containing the sequences.

Note

Halton, J.H., Smith, G.G., 1961. Algorithm 247 Radical-inverse quasi-random point sequence Computes a sequence of N quasi-random points lying in the K-dimensional unit cube given by 0 < x_i < 1, i = 1,2,..,K. The i-th component of the m-th point is stored in Q[m,i]. The sequence is initiated by a zero-th point stored in P, and each component sequence is iteratively generated with parameter R[i]. E is a positive error-parameter. K, N, E, P[i], R[i], i=1..K, are to be given.

Author(s)

Christian W. Hoffmann, hoffmann@wsl.ch

Source

J. H. Halton, 1964. Algorithm 247: Radical-inverse quasi-random point sequence, Communications of the ACM, Vol.7,12, pp. 701 - 702 .

References

http://en.wikipedia.org/wiki/Halton_sequences

Examples

par(mfrow=c(2,2))
 n <- 400
 q1 <- HS247(2,n,c(2,2),c(0,pi/10))
 q2 <- HS247(2,n,c(2,3))
 q3 <- HS247(2,n,c(2,5))
 q4 <- HS247(2,n,c(17,19)) # prone to correlations
 q5 <- HS247(2,n,c(2,3),c(pi/10,pi/10))
 of <- 0.2
 q6 <- HS247(2,n,c(2,3),c(pi/10+of,pi/10+of))
 ## Not run: 
   plot  (q1,pch="+",col="blue",cex=0.5,xlab="roots = (2,2), +blue, green")
   points(q2,pch=4, col="green",cex=0.5)
   plot  (q2,pch=4,col="green",cex=0.5,xlab="roots = (2,3),
          :green, (2,5) :red, (17,19) magenta")
   points(q3,pch=":",col="red")
   points(q4,pch=4,col="magenta",cex=0.5)
   plot  (q2,pch=4,col="green",cex=0.5,xlab="roots = 2, 2, green, red")
   points(q5,pch=5,cex=0.5,col="red")
   plot  (q5,pch=5,cex=0.5,col="red",xlab="roots = 2, 3, red")
   points(q6,pch="-")
 
## End(Not run)

cwhmisc

Miscellaneous Functions for Math, Plotting, Printing, Statistics, Strings, and Tools

v6.6
GPL (>= 2)
Authors
Christian W. Hoffmann
Initial release
2018-08-24, 10:40:10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.