RandomPivotingStrategy (Apache Commons Math 3.6.1 API)

org.apache.commons.math3.util

## Class RandomPivotingStrategy

- java.lang.Object
- - org.apache.commons.math3.util.RandomPivotingStrategy

- All Implemented Interfaces:
    Serializable, PivotingStrategyInterface

      public class RandomPivotingStrategy
      extends Object
      implements PivotingStrategyInterface, Serializable

  A strategy of selecting random index between begin and end indices.
  Since:
    3.4
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RandomPivotingStrategy(RandomGenerator random)` Simple constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `pivotIndex(double[] work, int begin, int end)` Find pivot index of the array so that partition and Kth element selection can be made

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RandomPivotingStrategy

          public RandomPivotingStrategy(RandomGenerator random)

      Simple constructor.
      Parameters:
        `random` - random generator to use for selecting pivot

  - ### Method Detail

    - #### pivotIndex

          public int pivotIndex(double[] work,
                       int begin,
                       int end)
                         throws MathIllegalArgumentException

      Find pivot index of the array so that partition and Kth element selection can be made A uniform random pivot selection between begin and end indices
      Specified by:
        `pivotIndex` in interface `PivotingStrategyInterface`
      Parameters:
        `work` - data array
        `begin` - index of the first element of the slice
        `end` - index after the last element of the slice
      Returns:
        The index corresponding to a random uniformly selected value between first and the last indices of the array slice
      Throws:
        `MathIllegalArgumentException` - when indices exceeds range

Copyright © 2003–2016 The Apache Software Foundation. All rights reserved.