Alex Herbert created RNG-133:
--------------------------------

             Summary: LineSampler: Sample uniformly within a line
                 Key: RNG-133
                 URL: https://issues.apache.org/jira/browse/RNG-133
             Project: Commons RNG
          Issue Type: New Feature
          Components: sampling
    Affects Versions: 1.4
            Reporter: Alex Herbert


Create a sampler to sample uniformly within a line:
{code:java}
public abstract class LineSampler implements 
        SharedStateSampler<LineSampler> {
    public static LineSampler of(double[] a,
                                    double[] b,
                                    UniformRandomProvider rng);
}
{code}

Sampling can be performed using the same method as the TriangleSampler without 
the third coordinate:
{noformat}
v = b - a
p = a + s * v

with s a uniform deviate in [0, 1]
{noformat}
To allow computation with any finite coordinates the vector does not require 
computation:
{noformat}
p = a + s * (b - a)
  = a + sb - sa
  = (1 - s)a + sb
{noformat}

This is the same method used in the {{ContinuousUniformSampler}} but extended 
to N-dimensions.




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to