Class UnitSphereSampler
java.lang.Object
org.apache.commons.rng.sampling.UnitSphereSampler
- All Implemented Interfaces:
ObjectSampler<double[]>, SharedStateObjectSampler<double[]>, SharedStateSampler<SharedStateObjectSampler<double[]>>
Generate vectors
isotropically located on the surface of a sphere.
Sampling in 2 or more dimensions uses:
Sampling in 1D uses the sign bit from UniformRandomProvider.nextInt() to set
the direction of the vector.
- Since:
- 1.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble[]Deprecated.Usesample().static UnitSphereSamplerof(UniformRandomProvider rng, int dimension) Create a unit sphere sampler for the given dimension.double[]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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ObjectSampler
samples, samples
-
Constructor Details
-
UnitSphereSampler
Deprecated.This instance delegates sampling. Use the factory methodof(UniformRandomProvider, int)to create an optimal sampler.- Parameters:
dimension- Space dimension.rng- Generator for the individual components of the vectors. A shallow copy will be stored in this instance.- Throws:
IllegalArgumentException- Ifdimension <= 0
-
-
Method Details
-
sample
Description copied from interface:ObjectSamplerCreate an object sample.- Specified by:
samplein interfaceObjectSampler<double[]>- Returns:
- a random normalized Cartesian vector.
- Since:
- 1.4
-
nextVector
Deprecated.Usesample().- Returns:
- a random normalized Cartesian vector.
-
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
- Since:
- 1.3
-
of
Create a unit sphere sampler for the given dimension.- Parameters:
rng- Generator for the individual components of the vectors. A shallow copy will be stored in the sampler.dimension- Space dimension.- Returns:
- the sampler
- Throws:
IllegalArgumentException- Ifdimension <= 0- Since:
- 1.4
-
of(UniformRandomProvider, int).