Class UnitBallSampler
java.lang.Object
org.apache.commons.rng.sampling.shape.UnitBallSampler
- All Implemented Interfaces:
ObjectSampler<double[]>, SharedStateObjectSampler<double[]>, SharedStateSampler<SharedStateObjectSampler<double[]>>
Generate coordinates
uniformly distributed within the unit n-ball.
Sampling uses:
UniformRandomProvider.nextLong()UniformRandomProvider.nextDouble()(only for dimensions above 2)
- Since:
- 1.4
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic UnitBallSamplerof(UniformRandomProvider rng, int dimension) Create a unit n-ball sampler for the given dimension.abstract double[]sample()Create an object sample.abstract UnitBallSamplerCreate 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ObjectSampler
samples, samples
-
Constructor Details
-
UnitBallSampler
public UnitBallSampler()Create an instance.
-
-
Method Details
-
sample
Description copied from interface:ObjectSamplerCreate an object sample.- Specified by:
samplein interfaceObjectSampler<double[]>- Returns:
- a random Cartesian coordinate within the unit n-ball.
-
withUniformRandomProvider
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:
withUniformRandomProviderin interfaceSharedStateSampler<SharedStateObjectSampler<double[]>>- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
of
Create a unit n-ball sampler for the given dimension. Sampled points are uniformly distributed within the unit n-ball.Sampling is supported in dimensions of 1 or above.
- Parameters:
rng- Source of randomness.dimension- Space dimension.- Returns:
- the sampler
- Throws:
IllegalArgumentException- Ifdimension <= 0
-