public class RandomBias
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static int |
BATHTUB_TRUNCATED
A constant for a distribution that linearly increases in probability from a 0.0 chance of 0.0.
|
int |
distribution |
static int |
EXP_TRI
A constant for a distribution that linearly increases in probability from a 0.0 chance of 0.0.
|
static int |
EXPONENTIAL
A constant for a distribution that linearly increases in probability from a 0.0 chance of 0.0.
|
IRNG |
rng |
static int |
SOFT_TRIANGULAR
A constant for a distribution that linearly increases in probability from a 0.0 chance of 0.0.
|
static int |
TRIANGULAR
A constant for a distribution that linearly increases in probability from a 0.0 chance of 0.0.
|
static int |
TRUNCATED
A constant for a distribution that linearly increases in probability from a 0.0 chance of 0.0.
|
Constructor and Description |
---|
RandomBias() |
RandomBias(IRNG rng) |
RandomBias(IRNG rng,
java.util.Map<java.lang.String,java.lang.Double> mapping) |
RandomBias(IRNG rng,
java.util.Map<java.lang.String,java.lang.Double> mapping,
int distribution) |
Modifier and Type | Method and Description |
---|---|
double |
biasedBetween(double expectedAverage,
double min,
double max)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
int |
biasedBetween(double expectedAverage,
int min,
int max)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
long |
biasedBetween(double expectedAverage,
long min,
long max)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
double |
biasedBetween(java.lang.String kind,
double min,
double max)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
int |
biasedBetween(java.lang.String kind,
int min,
int max)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
long |
biasedBetween(java.lang.String kind,
long min,
long max)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
boolean |
biasedBoolean(double expectedAverage)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
boolean |
biasedBoolean(java.lang.String kind)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
double |
biasedDouble(double expectedAverage)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
double |
biasedDouble(double expectedAverage,
double bound)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
double |
biasedDouble(java.lang.String kind)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
double |
biasedDouble(java.lang.String kind,
double bound)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
float |
biasedFloat(double expectedAverage)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
float |
biasedFloat(double expectedAverage,
float bound)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
float |
biasedFloat(java.lang.String kind)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
float |
biasedFloat(java.lang.String kind,
float bound)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
int |
biasedInt(double expectedAverage)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
int |
biasedInt(double expectedAverage,
int bound)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
int |
biasedInt(java.lang.String kind)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
int |
biasedInt(java.lang.String kind,
int bound)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
long |
biasedLong(double expectedAverage)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
long |
biasedLong(double expectedAverage,
long bound)
Generates a random number using this object's RNG and adjusts the generated number so it matches a distribution
that would have the given expected average.
|
long |
biasedLong(java.lang.String kind)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
long |
biasedLong(java.lang.String kind,
long bound)
Looks up the given kind in the Map of biases this stores, and generates a random number using this object's RNG.
|
RandomBias |
putBias(java.lang.String kind,
double expectedAverage)
Adds a kind of bias that can be used to change the average of random numbers generated when specified with that
kind.
|
RandomBias |
putBiases(java.util.Map<java.lang.String,java.lang.Double> mapping)
Adds a number of kinds of bias that can be used to change the average of random numbers generated when specified
with one of those kinds.
|
java.lang.String |
toString() |
public IRNG rng
public int distribution
public static final int TRIANGULAR
public static final int EXPONENTIAL
public static final int TRUNCATED
public static final int SOFT_TRIANGULAR
public static final int EXP_TRI
public static final int BATHTUB_TRUNCATED
public RandomBias()
public RandomBias(IRNG rng)
public RandomBias(IRNG rng, java.util.Map<java.lang.String,java.lang.Double> mapping)
public RandomBias(IRNG rng, java.util.Map<java.lang.String,java.lang.Double> mapping, int distribution)
public RandomBias putBias(java.lang.String kind, double expectedAverage)
kind
- a String that will be used as a key in a Map; can be given later on to bias results using this keyexpectedAverage
- above 0.0 and below 1.0, with 0.5 as the normal average but other values are more useful.public RandomBias putBiases(java.util.Map<java.lang.String,java.lang.Double> mapping)
mapping
- should have String keys that can be used later, and double values greater than 0 but less than 1.public long biasedLong(java.lang.String kind)
kind
- the kind of bias to look uppublic long biasedLong(java.lang.String kind, long bound)
kind
- the kind of bias to look upbound
- the outer bound, exclusive; can be negativepublic double biasedDouble(java.lang.String kind)
kind
- the kind of bias to look uppublic double biasedDouble(java.lang.String kind, double bound)
kind
- the kind of bias to look upbound
- the outer bound, exclusive; can be negativepublic int biasedInt(java.lang.String kind)
kind
- the kind of bias to look uppublic int biasedInt(java.lang.String kind, int bound)
kind
- the kind of bias to look upbound
- the outer bound, exclusive; can be negativepublic float biasedFloat(java.lang.String kind)
kind
- the kind of bias to look uppublic float biasedFloat(java.lang.String kind, float bound)
kind
- the kind of bias to look upbound
- the outer bound, exclusive; can be negativepublic boolean biasedBoolean(java.lang.String kind)
kind
- the kind of bias to look uppublic int biasedBetween(java.lang.String kind, int min, int max)
kind
- the kind of bias to look upmin
- the inner bound, inclusive; can be negativemax
- the outer bound, exclusive; can be negativepublic long biasedBetween(java.lang.String kind, long min, long max)
kind
- the kind of bias to look upmin
- the inner bound, inclusive; can be negativemax
- the outer bound, exclusive; can be negativepublic double biasedBetween(java.lang.String kind, double min, double max)
kind
- the kind of bias to look upmin
- the inner bound, inclusive; can be negativemax
- the outer bound, exclusive; can be negativepublic long biasedLong(double expectedAverage)
expectedAverage
- the desired average if the minimum value was 0.0 and the exclusive max was 1.0public long biasedLong(double expectedAverage, long bound)
expectedAverage
- the desired average if the minimum value was 0.0 and the exclusive max was 1.0bound
- the outer bound, exclusive; can be negativepublic double biasedDouble(double expectedAverage)
expectedAverage
- the desired averagepublic double biasedDouble(double expectedAverage, double bound)
expectedAverage
- the desired averagebound
- the outer bound, exclusive; can be negativepublic int biasedInt(double expectedAverage)
expectedAverage
- the desired average if the minimum value was 0.0 and the exclusive max was 1.0public int biasedInt(double expectedAverage, int bound)
expectedAverage
- the desired average if the minimum value was 0.0 and the exclusive max was 1.0bound
- the outer bound, exclusive; can be negativepublic float biasedFloat(double expectedAverage)
expectedAverage
- the desired averagepublic float biasedFloat(double expectedAverage, float bound)
expectedAverage
- the desired average if the minimum value was 0.0 and the exclusive max was 1.0bound
- the outer bound, exclusive; can be negativepublic boolean biasedBoolean(double expectedAverage)
expectedAverage
- the desired probability of a true result, between 0.0 and 1.0public int biasedBetween(double expectedAverage, int min, int max)
expectedAverage
- the desired average if the minimum value was 0.0 and the exclusive max was 1.0min
- the inner bound, inclusive; can be negativemax
- the outer bound, exclusive; can be negativepublic long biasedBetween(double expectedAverage, long min, long max)
expectedAverage
- the desired average if the minimum value was 0.0 and the exclusive max was 1.0min
- the inner bound, inclusive; can be negativemax
- the outer bound, exclusive; can be negativepublic double biasedBetween(double expectedAverage, double min, double max)
expectedAverage
- the desired average if the minimum value was 0.0 and the exclusive max was 1.0min
- the inner bound, inclusive; can be negativemax
- the outer bound, exclusive; can be negativepublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © Eben Howard 2012–2022. All rights reserved.