Class Probability
java.lang.Object
java.lang.Number
org.tweetyproject.math.probability.Probability
- All Implemented Interfaces:
- Serializable
This class represents a probability, i.e. a double in the interval [0,1].
- Author:
- Matthias Thimm
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final ProbabilityConstant for probability 1static final doubleThe precision for probabilities.static final ProbabilityConstant for probability 0
- 
Constructor SummaryConstructorsConstructorDescriptionProbability(Double value) Creates a new probability with the given valueProbability(Probability other) Creates a new probability from the given probability
- 
Method SummaryModifier and TypeMethodDescriptionadd(Probability other) Computes the sum of this and the given probability.Returns the complement of this probability, i.e.Divides this probability by given value returns the result.divide(Probability other) Divides this probability by other and returns the result.doublebooleanfloatgetValue()Returns the value of this probability.inthashCode()intintValue()booleanisWithinTolerance(Probability other) Checks whether the given probability is "nearly" the same as this probability (given the actual precision).longComputes the product of this probability and the given number.Computes the product of this probability and the given number.mult(Probability other) Computes the product of this probability and the given probability.booleansample()Returns a sample wrt.toString()Methods inherited from class java.lang.NumberbyteValue, shortValue
- 
Field Details- 
ONEConstant for probability 1
- 
ZEROConstant for probability 0
- 
PRECISIONpublic static final double PRECISIONThe precision for probabilities. TODO: that should go somewhere else.- See Also:
 
 
- 
- 
Constructor Details- 
ProbabilityCreates a new probability with the given value- Parameters:
- value- a double in the interval [0,1]
 
- 
ProbabilityCreates a new probability from the given probability- Parameters:
- other- another probability
 
 
- 
- 
Method Details- 
complementReturns the complement of this probability, i.e. a probability of one minus the value of this probability.- Returns:
- the complement of this probability.
 
- 
addComputes the sum of this and the given probability.- Parameters:
- other- a probability.
- Returns:
- a probability.
 
- 
multComputes the product of this probability and the given number.- Parameters:
- other- a number.
- Returns:
- a probability.
 
- 
multComputes the product of this probability and the given number.- Parameters:
- other- a number.
- Returns:
- a probability.
 
- 
multComputes the product of this probability and the given probability.- Parameters:
- other- a probability.
- Returns:
- a probability.
 
- 
divideDivides this probability by other and returns the result.- Parameters:
- other- a probability.
- Returns:
- a probability.
 
- 
divideDivides this probability by given value returns the result.- Parameters:
- other- a double value.
- Returns:
- a probability.
 
- 
isWithinToleranceChecks whether the given probability is "nearly" the same as this probability (given the actual precision).- Parameters:
- other- some probability
- Returns:
- "true" if the given probability is "nearly" the same as this one.
 
- 
samplepublic boolean sample()Returns a sample wrt. this probability, i.e. with this probability the value returned is "true", otherwise "false"- Returns:
- "true" with this probability.
 
- 
getValueReturns the value of this probability.- Returns:
- the value of this probability.
 
- 
doubleValuepublic double doubleValue()- Specified by:
- doubleValuein class- Number
 
- 
floatValuepublic float floatValue()- Specified by:
- floatValuein class- Number
 
- 
intValuepublic int intValue()
- 
longValuepublic long longValue()
- 
toString
- 
hashCodepublic int hashCode()
- 
equals
 
-