Class LineSampler

    • 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 coordinate on the line.
      • createSample

        protected abstract double[] createSample​(double p1mu,
                                                 double u)
        Creates the sample given the random variate u in the interval [0, 1]. The sum 1 - u is 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
      • of

        public static LineSampler of​(UniformRandomProvider rng,
                                     double[] a,
                                     double[] b)
        Create a line sampler with vertices a and b. Sampled points are uniformly distributed on the line segment ab.

        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.