public class Probability
extends java.lang.Number
Modifier and Type | Field and Description |
---|---|
static Probability |
ONE
Constant for probability 1
|
static double |
PRECISION
The precision for probabilities.
|
private static java.util.Random |
random
for sampling probabilities.
|
private static long |
serialVersionUID
For serialization
|
private java.lang.Double |
value
The actual value of the probability.
|
static Probability |
ZERO
Constant for probability 0
|
Constructor and Description |
---|
Probability(java.lang.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(java.lang.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(java.lang.Object obj) |
float |
floatValue() |
java.lang.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(java.lang.Double other)
Computes the product of this probability and the given number.
|
Probability |
mult(java.lang.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.
|
java.lang.String |
toString() |
public static final Probability ONE
public static final Probability ZERO
private static final java.util.Random random
public static final double PRECISION
private static final long serialVersionUID
private java.lang.Double value
public Probability(java.lang.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(java.lang.Double other)
other
- a number.public Probability mult(java.lang.Integer other)
other
- a number.public Probability mult(Probability other)
other
- a probability.public Probability divide(Probability other)
other
- a probability.public Probability divide(java.lang.Double other)
other
- a double value.public boolean isWithinTolerance(Probability other)
other
- some probabilitypublic boolean sample()
public java.lang.Double getValue()
public double doubleValue()
doubleValue
in class java.lang.Number
public float floatValue()
floatValue
in class java.lang.Number
public int intValue()
intValue
in class java.lang.Number
public long longValue()
longValue
in class java.lang.Number
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object