Uploaded image for project: 'Commons RNG'
  1. Commons RNG
  2. RNG-136

ObjectSampler<T> and SharedStateObjectSampler<T> interfaces

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Implemented
    • 1.4
    • 1.4
    • sampling
    • None

    Description

      The sampling package currently contains interfaces for creating int and double samples and their extensions to implement the SharedStateSampler interface:

      public interface DiscreteSampler {
          int sample();
      }
      public interface SharedStateDiscreteSampler
          extends DiscreteSampler, SharedStateSampler<SharedStateDiscreteSampler> {
          // Composite interface
      }
      public interface ContinuousSampler {
          double sample();
      }
      public interface SharedStateContinuousSampler
          extends ContinuousSampler, SharedStateSampler<SharedStateContinuousSampler> {
          // Composite interface
      }
      

      Add a matching ObjectSampler interface for all samplers that create objects:

      public interface ObjectSampler<T> {
          T sample();
      }
      public interface SharedStateObjectSampler<T> extends
              ObjectSampler<T>,
              SharedStateSampler<SharedStateObjectSampler<T>> {
          // Composite interface
      }
      

      Samplers currently returning an object should implement the new interface:

      int[] CombinationSampler.sample()
      int[] PermutationSampler.sample()
      double[] UnitSphereSampler.nextVector()
      T CollectionSampler<T>.sample()
      T DiscreteProbabilityCollectionSampler<T>.sample()
      double[] BoxSampler.sample()
      double[] LineSampler.sample()
      double[] TriangleSampler.sample()
      double[] TetrahedronSampler.sample()
      double[] UnitBallSampler.sample()
      

      Only the UnitVectorSampler will require a new sample method. The current nextVector method can be marked deprecated.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 20m
                1h 20m