Class TriangleSampler.TriangleSamplerND
java.lang.Object
org.apache.commons.rng.sampling.shape.TriangleSampler
org.apache.commons.rng.sampling.shape.TriangleSampler.TriangleSamplerND
- All Implemented Interfaces:
ObjectSampler<double[]>
,SharedStateObjectSampler<double[]>
,SharedStateSampler<SharedStateObjectSampler<double[]>>
- Enclosing class:
TriangleSampler
Sample uniformly from a triangle in ND.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTriangleSamplerND
(UniformRandomProvider rng, double[] a, double[] b, double[] c) -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
createSample
(double p1msmt, double s, double t) Creates the sample given the random variatess
andt
in the interval[0, 1]
ands + t <= 1
.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.shape.TriangleSampler
of, sample
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
-
a
private final double[] aThe first vertex. -
b
private final double[] bThe second vertex. -
c
private final double[] cThe third vertex.
-
-
Constructor Details
-
TriangleSamplerND
TriangleSamplerND(UniformRandomProvider rng, double[] a, double[] b, double[] c) - Parameters:
rng
- Source of randomness.a
- The first vertex.b
- The second vertex.c
- The third vertex.
-
TriangleSamplerND
TriangleSamplerND(UniformRandomProvider rng, TriangleSampler.TriangleSamplerND source) - Parameters:
rng
- Generator of uniformly distributed random numberssource
- Source to copy.
-
-
Method Details
-
createSample
public double[] createSample(double p1msmt, double s, double t) Description copied from class:TriangleSampler
Creates the sample given the random variatess
andt
in the interval[0, 1]
ands + t <= 1
. The sum1 - s - t
is provided. The sample can be obtained from the triangle abc using:p = a(1 - s - t) + sb + tc
- Specified by:
createSample
in classTriangleSampler
- Parameters:
p1msmt
- plus 1 minus s minus t (1 - s - t)s
- the first variate st
- the second variate t- Returns:
- the sample
-
withUniformRandomProvider
Description copied from class:TriangleSampler
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[]>>
- Specified by:
withUniformRandomProvider
in classTriangleSampler
- Parameters:
rng
- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-