find_inside | R Documentation |
Finds the center/a random point that is within the convex polytope defined by the
linear inequalities A*x <= b
or by the convex hull over the vertices in the matrix V
.
find_inside( A, b, V, options = NULL, random = FALSE, probs = TRUE, boundary = 1e-05 )
A |
a matrix with one row for each linear inequality constraint and one
column for each of the free parameters. The parameter space is defined
as all probabilities |
b |
a vector of the same length as the number of rows of |
V |
a matrix of vertices (one per row) that define the polytope of
admissible parameters as the convex hull over these points
(if provided, |
options |
optional: number of options per item type (only for A x ≤q b representation). Necessary to account for sum-to-one constraints within multinomial distributions (e.g., p_1 + p_2 + p_3 <= 1). By default, parameters are assumed to be independent. |
random |
if |
probs |
only for |
boundary |
constant value c that is subtracted on the right-hand side of the order constraints, A x ≤q b - c. This ensuresa that the resulting point is in the interior of the polytope and not at the boundary, which is important for MCMC sampling. |
If vertices V
are provided, a convex combination of the vertices is returned.
If random=TRUE
, the weights are drawn uniformly from a Dirichlet distribution.
If inequalities are provided via A
and b
, linear programming (LP) is used
to find the Chebyshev center of the polytope (i.e., the center of the largest ball that
fits into the polytope; the solution may not be unique). If random=TRUE
,
LP is used to find a random point (not uniformly sampled!) in the convex polytope.
# inequality representation (A*x <= b) A <- matrix( c( 1, -1, 0, 1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 1, -1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, -1, 0, 0, 0, 0 ), ncol = 5, byrow = TRUE ) b <- c(0.5, 0, 0, .7, .4, -.2) find_inside(A, b) find_inside(A, b, random = TRUE) # vertex representation V <- matrix(c( # strict weak orders 0, 1, 0, 1, 0, 1, # a < b < c 1, 0, 0, 1, 0, 1, # b < a < c 0, 1, 0, 1, 1, 0, # a < c < b 0, 1, 1, 0, 1, 0, # c < a < b 1, 0, 1, 0, 1, 0, # c < b < a 1, 0, 1, 0, 0, 1, # b < c < a 0, 0, 0, 1, 0, 1, # a ~ b < c 0, 1, 0, 0, 1, 0, # a ~ c < b 1, 0, 1, 0, 0, 0, # c ~ b < a 0, 1, 0, 1, 0, 0, # a < b ~ c 1, 0, 0, 0, 0, 1, # b < a ~ c 0, 0, 1, 0, 1, 0, # c < a ~ b 0, 0, 0, 0, 0, 0 # a ~ b ~ c ), byrow = TRUE, ncol = 6) find_inside(V = V) find_inside(V = V, random = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.