Class UnitBallSampler
- java.lang.Object
-
- org.apache.commons.rng.sampling.shape.UnitBallSampler
-
- All Implemented Interfaces:
ObjectSampler<double[]>,SharedStateObjectSampler<double[]>,SharedStateSampler<SharedStateObjectSampler<double[]>>
public abstract class UnitBallSampler extends Object implements 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 Constructor Description UnitBallSampler()Create an instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static UnitBallSamplerof(UniformRandomProvider rng, int dimension)Create a unit n-ball sampler for the given dimension.abstract double[]sample()Create an object sample.abstract UnitBallSamplerwithUniformRandomProvider(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
-
Methods inherited from interface org.apache.commons.rng.sampling.ObjectSampler
samples, samples
-
-
-
-
Constructor Detail
-
UnitBallSampler
public UnitBallSampler()
Create an instance.
-
-
Method Detail
-
sample
public abstract double[] 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
public abstract UnitBallSampler 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:
withUniformRandomProviderin interfaceSharedStateSampler<SharedStateObjectSampler<double[]>>- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
of
public static UnitBallSampler of(UniformRandomProvider rng, int dimension)
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
-
-