Package org.apache.commons.rng.sampling
Class UnitSphereSampler.UnitSphereSamplerND
java.lang.Object
org.apache.commons.rng.sampling.UnitSphereSampler
org.apache.commons.rng.sampling.UnitSphereSampler.UnitSphereSamplerND
- All Implemented Interfaces:
ObjectSampler<double[]>
,SharedStateObjectSampler<double[]>
,SharedStateSampler<SharedStateObjectSampler<double[]>>
- Enclosing class:
UnitSphereSampler
Sample uniformly from a ND unit sphere.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
Space dimension.private final NormalizedGaussianSampler
Sampler used for generating the individual components of the vectors. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
sample()
Create an object sample.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 org.apache.commons.rng.sampling.UnitSphereSampler
nextVector, of
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
-
Field Details
-
dimension
private final int dimensionSpace dimension. -
sampler
Sampler used for generating the individual components of the vectors.
-
-
Constructor Details
-
UnitSphereSamplerND
UnitSphereSamplerND(UniformRandomProvider rng, int dimension) - Parameters:
rng
- Source of randomness.dimension
- Space dimension.
-
-
Method Details
-
sample
public double[] sample()Description copied from interface:ObjectSampler
Create an object sample.- Specified by:
sample
in interfaceObjectSampler<double[]>
- Overrides:
sample
in classUnitSphereSampler
- Returns:
- a random normalized Cartesian vector.
-
withUniformRandomProvider
Description copied from class:UnitSphereSampler
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 interfaceSharedStateSampler<SharedStateObjectSampler<double[]>>
- Overrides:
withUniformRandomProvider
in classUnitSphereSampler
- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-