public class LinearDistributionNearbyRandom extends Object implements NearbyRandom
P(x) = 2/m - 2x/m²
.
Cumulative probability: F(x) = x(2m - x)/m²
.
Inverse cumulative probability: F(p) = m(1 - (1 - p)^(1/2))
.
Modifier and Type | Field and Description |
---|---|
protected int |
sizeMaximum |
Constructor and Description |
---|
LinearDistributionNearbyRandom(int sizeMaximum) |
Modifier and Type | Method and Description |
---|---|
int |
getOverallSizeMaximum()
Used to limit the RAM memory size of the nearby distance matrix.
|
int |
nextInt(Random random,
int nearbySize) |
public LinearDistributionNearbyRandom(int sizeMaximum)
public int nextInt(Random random, int nearbySize)
nextInt
in interface NearbyRandom
random
- never nullnearbySize
- never negative. The number of available values to select from.
Normally this is the size of the value range for a non-chained variable
and the size of the value range (= size of the entity list) minus 1 for a chained variable.0 <= x < nearbySize
public int getOverallSizeMaximum()
NearbyRandom
getOverallSizeMaximum
in interface NearbyRandom
NearbyRandom.nextInt(Random, int)
can return,
Integer.MAX_VALUE
if there is noneCopyright © 2006–2020 JBoss by Red Hat. All rights reserved.