public class Probability extends Number
| Modifier and Type | Field and Description |
|---|---|
static Probability |
ONE
Constant for probability 1
|
static double |
PRECISION
The precision for probabilities.
|
static Probability |
ZERO
Constant for probability 0
|
| Constructor and Description |
|---|
Probability(Double value)
Creates a new probability with the given value
|
Probability(Probability other)
Creates a new probability from the given probability
|
| Modifier and Type | Method and Description |
|---|---|
Probability |
add(Probability other)
Computes the sum of this and the given probability.
|
Probability |
complement()
Returns the complement of this probability, i.e.
|
Probability |
divide(Double other)
Divides this probability by given value returns the result.
|
Probability |
divide(Probability other)
Divides this probability by other and returns the result.
|
double |
doubleValue() |
boolean |
equals(Object obj) |
float |
floatValue() |
Double |
getValue()
Returns the value of this probability.
|
int |
hashCode() |
int |
intValue() |
boolean |
isWithinTolerance(Probability other)
Checks whether the given probability is "nearly" the same
as this probability (given the actual precision).
|
long |
longValue() |
Probability |
mult(Double other)
Computes the product of this probability and the given number.
|
Probability |
mult(Integer other)
Computes the product of this probability and the given number.
|
Probability |
mult(Probability other)
Computes the product of this probability and the given probability.
|
boolean |
sample()
Returns a sample wrt.
|
String |
toString() |
byteValue, shortValuepublic static final Probability ONE
public static final Probability ZERO
public static final double PRECISION
public Probability(Double value)
value - a double in the interval [0,1]public Probability(Probability other)
other - another probabilitypublic Probability complement()
public Probability add(Probability other)
other - a probability.public Probability mult(Double other)
other - a number.public Probability mult(Integer other)
other - a number.public Probability mult(Probability other)
other - a probability.public Probability divide(Probability other)
other - a probability.public Probability divide(Double other)
other - a double value.public boolean isWithinTolerance(Probability other)
other - some probabilitypublic boolean sample()
public Double getValue()
public double doubleValue()
doubleValue in class Numberpublic float floatValue()
floatValue in class NumberCopyright © 2018. All rights reserved.