Learn R Programming

volesti (version 1.0.0)

sample_points: Sample points from a convex Polytope (H-polytope, V-polytope or a zonotope) or use direct methods for uniform sampling from the unit or the canonical or an arbitrary \(d\)-dimensional simplex and the boundary or the interior of a \(d\)-dimensional hypersphere

Description

Sample N points with uniform or multidimensional spherical gaussian -centered in an internal point- target distribution. The \(d\)-dimensional unit simplex is the set of points \(\vec{x}\in \R^d\), s.t.: \(\sum_i x_i\leq 1\), \(x_i\geq 0\). The \(d\)-dimensional canonical simplex is the set of points \(\vec{x}\in \R^d\), s.t.: \(\sum_i x_i = 1\), \(x_i\geq 0\).

Usage

sample_points(P = NULL, N = NULL, distribution = NULL,
  WalkType = NULL, walk_step = NULL, exact = NULL, body = NULL,
  Parameters = NULL, InnerPoint = NULL)

Arguments

P

A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope.

N

The number of points that the function is going to sample from the convex polytope. The default value is \(100\).

distribution

Optional. A string that declares the target distribution: a) 'uniform' for the uniform distribution or b) 'gaussian' for the multidimensional spherical distribution. The default target distribution is uniform.

WalkType

Optional. A string that declares the random walk method: a) 'CDHR' for Coordinate Directions Hit-and-Run, b) 'RDHR' for Random Directions Hit-and-Run or c) 'BW' for Ball Walk. The default walk is 'CDHR'.

walk_step

Optional. The number of the steps for the random walk. The default value is \(\lfloor 10 + d/10\rfloor\), where \(d\) implies the dimension of the polytope.

exact

A boolean parameter. It should be used for the uniform sampling from the boundary or the interior of a hypersphere centered at the origin or from the unit or the canonical or an arbitrary simplex. The arbitrary simplex has to be given as a V-polytope. For the rest well known convex bodies the dimension has to be declared and the type of body as well as the radius of the hypersphere.

body

A string that declares the type of the body for the exact sampling: a) 'unit simplex' for the unit simplex, b) 'canonical simplex' for the canonical simplex, c) 'hypersphere' for the boundary of a hypersphere centered at the origin, d) 'ball' for the interior of a hypersphere centered at the origin.

Parameters

A list for the parameters of the methods:

  • variance The variance of the multidimensional spherical gaussian. The default value is 1.

  • dimension An integer that declares the dimension when exact sampling is enabled for a simplex or a hypersphere.

  • radius The radius of the \(d\)-dimensional hypersphere. The default value is \(1\).

  • BW_rad The radius for the ball walk.

InnerPoint

A \(d\)-dimensional numerical vector that defines a point in the interior of polytope P.

Value

A \(d\times N\) matrix that contains, column-wise, the sampled points from the convex polytope P.

References

R.Y. Rubinstein and B. Melamed, “Modern simulation and modeling” Wiley Series in Probability and Statistics, 1998.

A Smith, Noah and W Tromble, Roy, “Sampling Uniformly from the Unit Simplex,” Center for Language and Speech Processing Johns Hopkins University, 2004.

Art B. Owen, “Monte Carlo theory, methods and examples,” Art Owen, 2009.

Examples

Run this code
# NOT RUN {
# uniform distribution from the 3d unit cube in V-representation using ball walk
P = GenCube(3, 'V')
points = sample_points(P, WalkType = "BW", walk_step = 5)

# gaussian distribution from the 2d unit simplex in H-representation with variance = 2
A = matrix(c(-1,0,0,-1,1,1), ncol=2, nrow=3, byrow=TRUE)
b = c(0,0,1)
P = Hpolytope$new(A,b)
points = sample_points(P, distribution = "gaussian", Parameters = list("variance" = 2))

# uniform points from the boundary of a 10-dimensional hypersphere
points = sample_points(exact = TRUE, body = "hypersphere", Parameters = list("dimension" = 10))

# 10000 uniform points from a 2-d arbitrary simplex
V = matrix(c(2,3,-1,7,0,0),ncol = 2, nrow = 3, byrow = TRUE)
P = Vpolytope$new(V)
points = sample_points(P, N = 10000, exact = TRUE)
# }

Run the code above in your browser using DataLab