public class UnitSphereSampler extends Object implements SharedStateObjectSampler<double[]>
Sampling in 2 or more dimensions uses:
Sampling in 1D uses the sign bit from UniformRandomProvider.nextInt()
to set
the direction of the vector.
Constructor and Description |
---|
UnitSphereSampler(int dimension,
UniformRandomProvider rng)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
double[] |
nextVector()
Deprecated.
Use
sample() . |
static UnitSphereSampler |
of(UniformRandomProvider rng,
int dimension)
Create a unit sphere sampler for the given dimension.
|
double[] |
sample()
Create an object sample.
|
UnitSphereSampler |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
samples, samples
@Deprecated public UnitSphereSampler(int dimension, UniformRandomProvider rng)
of(UniformRandomProvider, int)
.of(UniformRandomProvider, int)
to create an optimal sampler.dimension
- Space dimension.rng
- Generator for the individual components of the vectors.
A shallow copy will be stored in this instance.IllegalArgumentException
- If dimension <= 0
public double[] sample()
ObjectSampler
sample
in interface ObjectSampler<double[]>
@Deprecated public double[] nextVector()
sample()
.public UnitSphereSampler withUniformRandomProvider(UniformRandomProvider rng)
withUniformRandomProvider
in interface SharedStateSampler<SharedStateObjectSampler<double[]>>
rng
- Generator of uniformly distributed random numbers.public static UnitSphereSampler of(UniformRandomProvider rng, int dimension)
rng
- Generator for the individual components of the vectors. A shallow
copy will be stored in the sampler.dimension
- Space dimension.IllegalArgumentException
- If dimension <= 0
Copyright © 2016–2022 The Apache Software Foundation. All rights reserved.