Compute and attach "inverse" or indices of the Halton sequence to points. Points can be an arbitrary set or a Halton lattice.
Either a data frame or a
This function works for dimensions >2 if
A vector of length D containing base powers.
DX2 matrix containing bounding box of the full set of Halton boxes.
First column of this matrix is the lower-left coordinate (i.e., minimums)
of the bounding box. Second column is the upper-right coordinate
(i.e., maximums) of the bounding box.
For example, if
A vector of length D containing Halton bases. These must be co-prime.
A character string giving the name of the column in
the output data frame or
A logical values specifying whether to invert the
Halton sequence using the Chinese Remainder Theorem (CRT). The other
Halton indices are the arguments to the Halton sequence. This routine is the inverse function for the Halton sequence. Given a point in D space, this routine computes the index (a non-negative integer) of the Halton sequence which maps to the Halton region containing the point.
For example, in 1D, with
bases == 2,
J == 3, and
all points in the interval [0,1/8) have Halton index equal to 0, all
point in [1/8,2/8) have Halton index 4, points in [2/8,3/8) have index
2, etc. To check, note that the Halton sequence maps x (mod 8) = 4 to the interval
[1/8,2/8), x (mod 8) = 2 are mapped to [2/8,3/8), etc. (i.e., check
range(halton(200)[(0:199) %% 8 == 4]) and
range(halton(200)[(0:199) %% 8 == 2]) )
x is a data frame,
x is returned
with an addition column. The additional column is named
and stores the index of the Halton box containing the point represented
on that line of
x is a
SpatialPointsDataFrame is returned containing the points in
The attributes of the returned object have an additional column, the index of the Halton
box containing the point. Name of the attribute is
If multiple points fall in the same Halton box, their Halton indices are
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# The following is equivalent to hal.point(WA.cities,25,J=c(3,2)) # # Add tiny amount to right and top of bounding box because Halton boxes are # closed on the left and bottom. This includes points exactly on the bounding lines. bb <- bbox(WA.cities) + c(0,0,1,1) # Compute Halton indices frame <- halton.indices( WA.cities, J=c(3,2), hl.bbox=bb ) # Construct Halton frame frame <- halton.frame( frame ) # Draw HAL sample n <- 25 N.frame <- nrow(frame) m <- floor(runif(1, 0, N.frame)) # Integer 0,...,N.frame-1 ind <- (((0:(n-1))+m) %% N.frame ) + 1 # Cycle around frame if necessary samp <- frame[ind,] # draw sample
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.