## Class BoxSampler

• All Implemented Interfaces:
ObjectSampler<double[]>, SharedStateObjectSampler<double[]>, SharedStateSampler<SharedStateObjectSampler<double[]>>

public abstract class BoxSampler
extends Object
implements SharedStateObjectSampler<double[]>
Generate points uniformly distributed within a n-dimension box (hyperrectangle).

Sampling uses:

Since:
1.4
Hyperrectangle (Wikipedia)
• ### Method Summary

All Methods
Modifier and Type Method Description
static BoxSampler of​(UniformRandomProvider rng, double[] a, double[] b)
Create a box sampler with bounds a and b.
abstract double[] sample()
Create a sample.
abstract BoxSampler withUniformRandomProvider​(UniformRandomProvider rng)
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Method Detail

• #### sample

public abstract double[] sample()
Description copied from interface: ObjectSampler
Create a sample.
Specified by:
sample in interface ObjectSampler<double[]>
Returns:
a random Cartesian coordinate within the box.
• #### withUniformRandomProvider

public abstract BoxSampler withUniformRandomProvider​(UniformRandomProvider rng)
Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.
Specified by:
withUniformRandomProvider in interface SharedStateSampler<SharedStateObjectSampler<double[]>>
Parameters:
rng - Generator of uniformly distributed random numbers.
Returns:
the sampler
• #### of

public static BoxSampler of​(UniformRandomProvider rng,
double[] a,
double[] b)
Create a box sampler with bounds a and b. Sampled points are uniformly distributed within the box defined by the bounds.

Sampling is supported in dimensions of 2 or above. Single dimension sampling can be performed using a LineSampler.

Note: There is no requirement that a <= b. The samples will be uniformly distributed in the range a to b for each dimension.

Parameters:
rng - Source of randomness.
a - Bound a.
b - Bound b.
Returns:
the sampler
Throws:
IllegalArgumentException - If the bounds do not have the same dimension; the dimension is less than 2; or bounds have non-finite coordinates.