Class TriangleSampler.TriangleSampler2D
- java.lang.Object
-
- org.apache.commons.rng.sampling.shape.TriangleSampler
-
- org.apache.commons.rng.sampling.shape.TriangleSampler.TriangleSampler2D
-
- All Implemented Interfaces:
ObjectSampler<double[]>,SharedStateObjectSampler<double[]>,SharedStateSampler<SharedStateObjectSampler<double[]>>
- Enclosing class:
- TriangleSampler
private static final class TriangleSampler.TriangleSampler2D extends TriangleSampler
Sample uniformly from a triangle in 2D. This is an non-array based specialisation ofTriangleSampler.TriangleSamplerNDfor performance.
-
-
Field Summary
Fields Modifier and Type Field Description private doubleaxThe x component of vertex a.private doubleayThe y component of vertex a.private doublebxThe x component of vertex b.private doublebyThe y component of vertex b.private doublecxThe x component of vertex c.private doublecyThe y component of vertex c.
-
Constructor Summary
Constructors Constructor Description TriangleSampler2D(UniformRandomProvider rng, double[] a, double[] b, double[] c)TriangleSampler2D(UniformRandomProvider rng, TriangleSampler.TriangleSampler2D source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double[]createSample(double p1msmt, double s, double t)Creates the sample given the random variatessandtin the interval[0, 1]ands + t <= 1.TriangleSamplerwithUniformRandomProvider(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.-
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 Detail
-
ax
private final double ax
The x component of vertex a.
-
ay
private final double ay
The y component of vertex a.
-
bx
private final double bx
The x component of vertex b.
-
by
private final double by
The y component of vertex b.
-
cx
private final double cx
The x component of vertex c.
-
cy
private final double cy
The y component of vertex c.
-
-
Constructor Detail
-
TriangleSampler2D
TriangleSampler2D(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.
-
TriangleSampler2D
TriangleSampler2D(UniformRandomProvider rng, TriangleSampler.TriangleSampler2D source)
- Parameters:
rng- Generator of uniformly distributed random numberssource- Source to copy.
-
-
Method Detail
-
createSample
public double[] createSample(double p1msmt, double s, double t)Description copied from class:TriangleSamplerCreates the sample given the random variatessandtin the interval[0, 1]ands + t <= 1. The sum1 - s - tis provided. The sample can be obtained from the triangle abc using:p = a(1 - s - t) + sb + tc
- Specified by:
createSamplein 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
public TriangleSampler withUniformRandomProvider(UniformRandomProvider rng)
Description copied from class:TriangleSamplerCreate 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[]>>- Specified by:
withUniformRandomProviderin classTriangleSampler- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-
-