## org.apache.mahout.math.jet.random.sampling
Class RandomSampler

    java.lang.Object
      org.apache.mahout.math.PersistentObject
          org.apache.mahout.math.jet.random.sampling.RandomSampler

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable

Deprecated. until unit tests are in place. Until this time, this class/interface is unsupported.

    @Deprecated
    public class RandomSampler

extends org.apache.mahout.math.PersistentObject

See Also:
  Serialized Form

Constructor Summary
`RandomSampler(long n, long N, long low, java.util.Random randomGenerator)` Deprecated. Constructs a random sampler that computes and delivers sorted random sets in blocks.

Method Summary
`void` `nextBlock(int count, long[] values, int fromIndex)` Deprecated. Computes the next `count` random numbers of the sorted random set specified on instance construction and fills them into `values`, starting at index `fromIndex`.
`protected static void` `rejectMethodD(long n, long N, int count, long low, long[] values, int fromIndex, java.util.Random randomGenerator)` Deprecated. Efficiently computes a sorted random set of `count` elements from the interval `[low,low+N-1]`.
`static void` `sample(long n, long N, int count, long low, long[] values, int fromIndex, java.util.Random randomGenerator)` Deprecated. Efficiently computes a sorted random set of `count` elements from the interval `[low,low+N-1]`.
`protected static void` `sampleMethodA(long n, long N, int count, long low, long[] values, int fromIndex, java.util.Random randomGenerator)` Deprecated. Computes a sorted random set of `count` elements from the interval `[low,low+N-1]`.
`protected static void` `sampleMethodD(long n, long N, int count, long low, long[] values, int fromIndex, java.util.Random randomGenerator)` Deprecated. Efficiently computes a sorted random set of `count` elements from the interval `[low,low+N-1]`.

Methods inherited from class org.apache.mahout.math.PersistentObject
`clone`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RandomSampler

    public RandomSampler(long n,
                         long N,
                         long low,
                         java.util.Random randomGenerator)

  Deprecated.
  Constructs a random sampler that computes and delivers sorted random sets in blocks. A set block can be retrieved with method `nextBlock`. Successive calls to method `nextBlock` will deliver as many random numbers as required.

  Parameters:
    `n` - the total number of elements to choose (must be `n >= 0` and `n <= N`).
    `N` - the interval to choose random numbers from is `[low,low+N-1]`.
    `low` - the interval to choose random numbers from is `[low,low+N-1]`. Hint: If `low==0`, then random numbers will be drawn from the interval `[0,N-1]`.
    `randomGenerator` - a random number generator. Set this parameter to `null` to use the default random number generator.

Method Detail

### nextBlock

    public void nextBlock(int count,
                          long[] values,
                          int fromIndex)

  Deprecated.
  Computes the next `count` random numbers of the sorted random set specified on instance construction and fills them into `values`, starting at index `fromIndex`.

  Numbers are filled into the specified array starting at index `fromIndex` to the right. The array is returned sorted ascending in the range filled with numbers.

  Parameters:
    `count` - the number of elements to be filled into `values` by this call (must be >= 0).
    `values` - the array into which the random numbers are to be filled; must have a length `>= count+fromIndex`.
    `fromIndex` - the first index within `values` to be filled with numbers (inclusive).

### rejectMethodD

    protected static void rejectMethodD(long n,
                                        long N,
                                        int count,
                                        long low,
                                        long[] values,
                                        int fromIndex,
                                        java.util.Random randomGenerator)

  Deprecated.
  Efficiently computes a sorted random set of `count` elements from the interval `[low,low+N-1]`. Since we are talking about a random set, no element will occur more than once.

  Running time is `O(count)`, on average. Space requirements are zero.

  Numbers are filled into the specified array starting at index `fromIndex` to the right. The array is returned sorted ascending in the range filled with numbers.

  Parameters:
    `n` - the total number of elements to choose (must be >= 0).
    `N` - the interval to choose random numbers from is `[low,low+N-1]`.
    `count` - the number of elements to be filled into `values` by this call (must be >= 0 and <=`n`). Normally, you will set `count=n`.
    `low` - the interval to choose random numbers from is `[low,low+N-1]`. Hint: If `low==0`, then draws random numbers from the interval `[0,N-1]`.
    `values` - the array into which the random numbers are to be filled; must have a length `>= count+fromIndex`.
    `fromIndex` - the first index within `values` to be filled with numbers (inclusive).
    `randomGenerator` - a random number generator.

### sample

    public static void sample(long n,
                              long N,
                              int count,
                              long low,
                              long[] values,
                              int fromIndex,
                              java.util.Random randomGenerator)

  Deprecated.
  Efficiently computes a sorted random set of `count` elements from the interval `[low,low+N-1]`. Since we are talking about a random set, no element will occur more than once.

  Running time is `O(count)`, on average. Space requirements are zero.

  Numbers are filled into the specified array starting at index `fromIndex` to the right. The array is returned sorted ascending in the range filled with numbers.

  Random number generation: By default uses `MersenneTwister`, a very strong random number generator, much better than `java.util.Random`. You can also use other strong random number generators of Paul Houle's RngPack package. For example, `Ranecu`, `Ranmar` and `Ranlux` are strong well analyzed research grade pseudo-random number generators with known periods.

  Parameters:
    `n` - the total number of elements to choose (must be `n >= 0` and `n <= N`).
    `N` - the interval to choose random numbers from is `[low,low+N-1]`.
    `count` - the number of elements to be filled into `values` by this call (must be >= 0 and <=`n`). Normally, you will set `count=n`.
    `low` - the interval to choose random numbers from is `[low,low+N-1]`. Hint: If `low==0`, then draws random numbers from the interval `[0,N-1]`.
    `values` - the array into which the random numbers are to be filled; must have a length `>= count+fromIndex`.
    `fromIndex` - the first index within `values` to be filled with numbers (inclusive).
    `randomGenerator` - a random number generator. Set this parameter to `null` to use the default random number generator.

### sampleMethodA

    protected static void sampleMethodA(long n,
                                        long N,
                                        int count,
                                        long low,
                                        long[] values,
                                        int fromIndex,
                                        java.util.Random randomGenerator)

  Deprecated.
  Computes a sorted random set of `count` elements from the interval `[low,low+N-1]`. Since we are talking about a random set, no element will occur more than once.

  Running time is `O(N)`, on average. Space requirements are zero.

  Numbers are filled into the specified array starting at index `fromIndex` to the right. The array is returned sorted ascending in the range filled with numbers.

  Parameters:
    `n` - the total number of elements to choose (must be >= 0).
    `N` - the interval to choose random numbers from is `[low,low+N-1]`.
    `count` - the number of elements to be filled into `values` by this call (must be >= 0 and <=`n`). Normally, you will set `count=n`.
    `low` - the interval to choose random numbers from is `[low,low+N-1]`. Hint: If `low==0`, then draws random numbers from the interval `[0,N-1]`.
    `values` - the array into which the random numbers are to be filled; must have a length `>= count+fromIndex`.
    `fromIndex` - the first index within `values` to be filled with numbers (inclusive).
    `randomGenerator` - a random number generator.

### sampleMethodD

    protected static void sampleMethodD(long n,
                                        long N,
                                        int count,
                                        long low,
                                        long[] values,
                                        int fromIndex,
                                        java.util.Random randomGenerator)

  Deprecated.
  Efficiently computes a sorted random set of `count` elements from the interval `[low,low+N-1]`. Since we are talking about a random set, no element will occur more than once.

  Running time is `O(count)`, on average. Space requirements are zero.

  Numbers are filled into the specified array starting at index `fromIndex` to the right. The array is returned sorted ascending in the range filled with numbers.

  Parameters:
    `n` - the total number of elements to choose (must be >= 0).
    `N` - the interval to choose random numbers from is `[low,low+N-1]`.
    `count` - the number of elements to be filled into `values` by this call (must be >= 0 and <=`n`). Normally, you will set `count=n`.
    `low` - the interval to choose random numbers from is `[low,low+N-1]`. Hint: If `low==0`, then draws random numbers from the interval `[0,N-1]`.
    `values` - the array into which the random numbers are to be filled; must have a length `>= count+fromIndex`.
    `fromIndex` - the first index within `values` to be filled with numbers (inclusive).
    `randomGenerator` - a random number generator.

Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.