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

Add stream methods to the sampler API

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Implemented
    • 1.4
    • 1.5
    • sampling
    • None
    • Easy

    Description

      Add default stream implementations to the sampler API interfaces

      • ContinuousSampler - DoubleStream
      • DiscreteSampler - IntStream
      • LongSampler - LongStream
      • ObjectSampler<T> - Stream<T>

      e.g.

      default DoubleStream samples() {
          return DoubleStream.generate(this::sample).sequential();
      }  
      
      default DoubleStream samples(long streamSize) {
          return samples().limit(streamSize);
      }  

      This allows for example:

      UniformRandomProvider rng = ...;
      double[] data = ContinuousUniformSampler.of(rng, 1.23, 4.56)
                                              .samples(50)
                                              .toArray(); 

      Attachments

        Issue Links

          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 - 0.5h
                  0.5h