Class TetrahedronSampler

    • Field Detail

      • THREE_D

        private static final int THREE_D
        The dimension for 3D sampling.
        See Also:
        Constant Field Values
      • VERTEX_A

        private static final java.lang.String VERTEX_A
        The name of vertex a.
        See Also:
        Constant Field Values
      • VERTEX_B

        private static final java.lang.String VERTEX_B
        The name of vertex b.
        See Also:
        Constant Field Values
      • VERTEX_C

        private static final java.lang.String VERTEX_C
        The name of vertex c.
        See Also:
        Constant Field Values
      • VERTEX_D

        private static final java.lang.String VERTEX_D
        The name of vertex d.
        See Also:
        Constant Field Values
      • a

        private final double[] a
        The first vertex.
      • b

        private final double[] b
        The second vertex.
      • c

        private final double[] c
        The third vertex.
      • d

        private final double[] d
        The fourth vertex.
    • Constructor Detail

      • TetrahedronSampler

        TetrahedronSampler​(UniformRandomProvider rng,
                           double[] a,
                           double[] b,
                           double[] c,
                           double[] d)
        Parameters:
        rng - Source of randomness.
        a - The first vertex.
        b - The second vertex.
        c - The third vertex.
        d - The fourth vertex.
    • Method Detail

      • sample

        public double[] sample()
        Description copied from interface: ObjectSampler
        Create an object sample.
        Specified by:
        sample in interface ObjectSampler<double[]>
        Returns:
        a random Cartesian point within the tetrahedron.
      • createSample

        private double[] createSample​(double p1msmtmu,
                                      double s,
                                      double t,
                                      double u)
        Creates the sample given the random variates s, t and u in the interval [0, 1] and s + t + u <= 1. The sum 1 - s - t - u is provided. The sample can be obtained from the tetrahedron abcd using:
         p = (1 - s - t - u)a + sb + tc + ud
         
        Parameters:
        p1msmtmu - plus 1 minus s minus t minus u (1 - s - t - u)
        s - the first variate s
        t - the second variate t
        u - the third variate u
        Returns:
        the sample
      • of

        public static TetrahedronSampler of​(UniformRandomProvider rng,
                                            double[] a,
                                            double[] b,
                                            double[] c,
                                            double[] d)
        Create a tetrahedron sampler with vertices a, b, c and d. Sampled points are uniformly distributed within the tetrahedron.

        No test for a volume is performed. If the vertices are coplanar the sampling distribution is undefined.

        Parameters:
        rng - Source of randomness.
        a - The first vertex.
        b - The second vertex.
        c - The third vertex.
        d - The fourth vertex.
        Returns:
        the sampler
        Throws:
        java.lang.IllegalArgumentException - If the vertices do not have length 3; or vertices have non-finite coordinates