Top Description Fields Constructors Methods
org.apache.commons.math3.util

public Class RandomPivotingStrategy

extends Object
implements PivotingStrategyInterface, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.math3.util.PivotingStrategyInterface
Imports
java.io.Serializable, org.apache.commons.math3.exception.MathIllegalArgumentException, org.apache.commons.math3.random.RandomGenerator

A strategy of selecting random index between begin and end indices.
Since
3.4

Field Summary

Modifier and TypeField and Description
private final RandomGenerator
random

Random generator to use for selecting pivot.

private static final long
serialVersionUID

Serializable UID.

Constructor Summary

AccessConstructor and Description
public
RandomPivotingStrategy(final RandomGenerator
random generator to use for selecting pivot
random
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The index corresponding to a random uniformly selected value between first and the last indices of the array slice
pivotIndex
(final double[]
data array
work
,
final int
index of the first element of the slice
begin
,
final int
index after the last element of the slice
end
)

Implements org.apache.commons.math3.util.PivotingStrategyInterface.pivotIndex.

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

randomback to summary
private final RandomGenerator random

Random generator to use for selecting pivot.

serialVersionUIDback to summary
private static final long serialVersionUID

Serializable UID.

Constructor Detail

RandomPivotingStrategyback to summary
public RandomPivotingStrategy(final RandomGenerator random)

Simple constructor.

Parameters
random:RandomGenerator

random generator to use for selecting pivot

Method Detail

pivotIndexback to summary
public int pivotIndex(final double[] work, final int begin, final int end) throws MathIllegalArgumentException

Implements org.apache.commons.math3.util.PivotingStrategyInterface.pivotIndex.

Doc from org.apache.commons.math3.util.PivotingStrategyInterface.pivotIndex.

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

Parameters
work:double[]

data array

begin:int

index of the first element of the slice

end:int

index after the last element of the slice

Returns:int

The index corresponding to a random uniformly selected value between first and the last indices of the array slice

Exceptions
MathIllegalArgumentException:
when indices exceeds range