Class LineSampler
java.lang.Object
org.apache.commons.rng.sampling.shape.LineSampler
- All Implemented Interfaces:
ObjectSampler<double[]>, SharedStateObjectSampler<double[]>, SharedStateSampler<SharedStateObjectSampler<double[]>>
Generate points uniformly distributed on a line.
Sampling uses:
- Since:
- 1.4
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract double[]createSample(double p1mu, double u) Creates the sample given the random variateuin the interval[0, 1].static LineSamplerof(UniformRandomProvider rng, double[] a, double[] b) Create a line sampler with verticesaandb.double[]sample()Create an object sample.abstract LineSamplerCreate 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
-
Method Details
-
sample
Description copied from interface:ObjectSamplerCreate an object sample.- Specified by:
samplein interfaceObjectSampler<double[]>- Returns:
- a random Cartesian coordinate on the line.
-
createSample
Creates the sample given the random variateuin the interval[0, 1]. The sum1 - uis provided. The sample can be obtained from the line ab using:p = a(1 - u) + ub
- Parameters:
p1mu- plus 1 minus u (1 - u)u- the variate u- Returns:
- the sample
-
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 line sampler with verticesaandb. Sampled points are uniformly distributed on the line segmentab.Sampling is supported in dimensions of 1 or above.
- Parameters:
rng- Source of randomness.a- The first vertex.b- The second vertex.- Returns:
- the sampler
- Throws:
IllegalArgumentException- If the vertices do not have the same dimension; the dimension is less than 1; or vertices have non-finite coordinates.
-