Package jline.api.mam
Class RandpKt
-
- All Implemented Interfaces:
public final class RandpKt
-
-
Method Summary
Modifier and Type Method Description final static Matrix
randp(DoubleArray P, Integer rows, Integer cols)
Pick random values with relative probability. final static Matrix
randp(Matrix P, Integer rows, Integer cols)
Pick random values with relative probability (Matrix version). final static Integer
randp(DoubleArray P)
Generate a single random sample with relative probability. final static Integer
randp(Matrix P)
Generate a single random sample with relative probability (Matrix version). -
-
Method Detail
-
randp
final static Matrix randp(DoubleArray P, Integer rows, Integer cols)
Pick random values with relative probability.
Returns integers in the range from 1 to PROB.size with a relative probability, so that the value X is present approximately (PROBX-1/sum(PROB)) times.
All values of PROB should be equal to or larger than 0.
- Parameters:
P
- Probability vector (all values should be >= 0)rows
- Number of rows for output matrixcols
- Number of columns for output matrix (defaults to rows if not specified)- Returns:
Matrix of random integers with specified probabilities
-
randp
final static Matrix randp(Matrix P, Integer rows, Integer cols)
Pick random values with relative probability (Matrix version).
- Parameters:
P
- Probability matrix (flattened column-wise)rows
- Number of rows for output matrixcols
- Number of columns for output matrix (defaults to rows if not specified)- Returns:
Matrix of random integers with specified probabilities
-
randp
final static Integer randp(DoubleArray P)
Generate a single random sample with relative probability.
- Parameters:
P
- Probability vector- Returns:
Single random integer with specified probability
-
-
-
-