hitandrun: Samples from Ax=b and w>0.

Description Usage Arguments Details Value Author(s) Examples

Description

Uniformly samples from a convex polytope given by linear equalities in the parameters using a hit-and-run algorithm. Given constraints: Ax = b and x ≥ 0 the algorithm finds a point on the interior of the constraints. From there it picks a direction in the k-plane defined by Ax = b and then calculates the maximum and minimum distances (tmin and tmax) it can move in that direction. It picks a random distance to travel between tmin and tmax and this is used as the next point. This algorithm is useful because each sample is made in constant time.

Usage

1
2
hitandrun(A, b, n, discard = 1000, skiplength = 5, chains = 1,
  verbose = FALSE, achr = FALSE)

Arguments

A

Matrix of constraint coefficients, rows should correspond to each constraint. A must not have collinear rows

b

A vector corresponding to the right hand side of the constraints

n

The number of output vectors desired

discard

A burninlength, how many vectors should be discarded before recording

skiplength

Only 1 out of every 'skiplength' vectors will be recorded

chains

number of different chains, starting from different starting points

verbose

Give verbose output of how the function is progressing.

achr

Whether to use "accelerated convergence hit and run" algorithm proposed in paper: <Insert Kaufman, Smith citation>. "discard" will be used to collect presamples to estimate the expected value of the span.

Details

To find tmin and tmax, we must find the first component that becomes zero when going in the negative or positive direction (t). We have that x_i + u_it = 0 or t = =-\frac{x_i}{u_i}. We must find the minimum and maximum for positive and negative t, respectively, in i. Once those bounds are found, a value of t is picked uniformly on the interval between tmin and tmax.

Value

Gives back a list of matrices with 'n' columns corrresponding to n uniformly sampled solutions of Ax = b. The number of lists = "chains" variable. 'n' columns.

Author(s)

Mike Flynn mflynn210@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
A <- matrix(1, ncol = 5, nrow = 1)
b <- 1
w <- hitandrun(A, b, n = 100)

A <- matrix(1, ncol = 100, nrow = 1)
b <- 50
A <- rbind(A, rnorm(100))
b <- c(b,0)
w <- hitandrun(A, b, n = 100)

##2 chains
chains.2 <- hitandrun(A, b, n = 10, chains = 2)

davidkane9/kmatching documentation built on May 15, 2019, 1:14 a.m.