Description Usage Arguments Details Value Author(s) See Also Examples
Compute and attach "inverse" or indices of the Halton sequence to points. Points can be an arbitrary set or a Halton lattice.
1 2 | halton.indices(x, J = NULL, hl.bbox, bases = c(2, 3),
index.name = "HaltonIndex", use.CRT = FALSE)
|
x |
Either a data frame or a If This function works for dimensions >2 if |
J |
A vector of length D containing base powers. |
hl.bbox |
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 |
bases |
A vector of length D containing Halton bases. These must be co-prime. |
index.name |
A character string giving the name of the column in
the output data frame or |
use.CRT |
A logical values specifying whether to invert the
Halton sequence using the Chinese Remainder Theorem (CRT). The other
method ( |
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
hl.bbox= matrix(c(0,1),1),
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]) )
If x is a data frame, x is returned
with an addition column. The additional column is named index.name
and stores the index of the Halton box containing the point represented
on that line of x. If x is a SpatialPoints* object,
a SpatialPointsDataFrame is returned containing the points in x.
The attributes of the returned object have an additional column, the index of the Halton
box containing the point. Name of the attribute is index.name.
If multiple points fall in the same Halton box, their Halton indices are
identical.
Trent McDonald
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # The following is equivalent to hip.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.