Uploaded image for project: 'Commons Statistics'
  1. Commons Statistics
  2. STATISTICS-33

Remove the utility function to create an array of samples from a Sampler

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Implemented
    • 1.0
    • 1.0
    • distribution
    • None

    Description

      The following utility methods can be removed:

      abstract class AbstractDiscreteDistribution {
          public static int[] sample(int n,
                                     DiscreteDistribution.Sampler sampler)
      }
      
      abstract class AbstractContinuousDistribution {
          public static double[] sample(int n,
                                        ContinuousDistribution.Sampler sampler)
      }
      
      

      They exists as utility methods in a package-private abstract class (thus the public modifier is confusing). I suggest moving them to TestUtils. They can be replicated in code by using a stream:

      ContinuousDistribution d = ...;
      UniformRandomProvider rng = ...;
      int n = 1000;
      double[] samples = DoubleStream.stream(d.createSampler(rng)::sample)
                                     .limit(n)
                                     .toArray();
      

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            aherbert Alex Herbert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: