hitandrun-package {hitandrun} | R Documentation |
"Hit and Run" sampling
Description
This package provides a "Hit and Run" sampler that generates a Markov chain whose stable state converges on the uniform distribution over a convex polytope.
The polytope is given by a set of inequality constraints in standard linear programming form (Ax \leq b
) and optionally a set of equality constraints.
In addition, there is a "Shake and Bake" sampler to generate points from the boundary of such a shape.
Utilities are provided for sampling from subsets of the unit simplex (i.e. random variates that can be interpreted as weights satisfying certain constraints) and for specifying common constraints.
Details
hitandrun
and shakeandbake
now provide the most general interface for sampling from spaces defined by arbitrary linear equality and inequality constraints. The functions described in the following provide lower level functionality on which it is built.
har
is the core "Hit and Run" sampler, sab
is the core "Shake and Bake" sampler, bbReject
is the bounding box rejection sampler, and simplex.sample
samples uniformly from the unit simplex.
See simplex.createTransform
and simplex.createConstraints
for sampling from subsets of the unit simplex.
Utilities to specify common constraints are described in harConstraints
.
When the sampling space is restricted by different linear equality constraints, use solution.basis
, createTransform
, and transformConstraints
.
This is a generalization of the methods for sampling from the simplex.
Note
"Hit and Run" is a Markov Chain Monte Carlo (MCMC) method, so generated samples form a correlated time series. To get a uniform sample, you need O^*(n^3)
samples, where n is the dimension of the sampling space.
Author(s)
Maintainer: Gert van Valkenhoef <gert@gertvv.nl>
References
Tervonen, T., van Valkenhoef, G., Basturk, N., and Postmus, D. (2012) "Hit-And-Run enables efficient weight generation for simulation-based multiple criteria decision analysis". European Journal of Operational Research 224(3) 552-559. doi: 10.1016/j.ejor.2012.08.026 van Valkenhoef, G., Tervonen, T., and Postmus, D. (2014) "Notes on 'Hit-And-Run enables efficient weight generation for simulation-based multiple criteria decision analysis'". European Journal of Operational Research (in press). doi: 10.1016/j.ejor.2014.06.036
See Also
bbReject
simplex.sample
hypersphere.sample
solution.basis
createTransform
transformConstraints
simplex.createTransform
simplex.createConstraints
createSeedPoint
createBoundBox
Examples
# Example: sample weight vectors where w_1 >= w_2 and w_1 >= w_3
n <- 3 # length of weight vector
constr <- mergeConstraints(
ordinalConstraint(n, 1, 2),
ordinalConstraint(n, 1, 3))
transform <- simplex.createTransform(n)
constr <- simplex.createConstraints(transform, constr)
seedPoint <- createSeedPoint(constr, homogeneous=TRUE)
N <- 1000
w <- har(seedPoint, constr, N=N * (n-1)^3, thin=(n-1)^3,
homogeneous=TRUE, transform=transform)$samples
stopifnot(all(w[,1] >= w[,2]) && all(w[,1] >= w[,3]))