Package net.sf.tweety.commons.util
Class MathTools
- java.lang.Object
-
- net.sf.tweety.commons.util.MathTools
-
public class MathTools extends java.lang.Object
This class contains some useful math tools.- Author:
- Matthias Thimm
-
-
Constructor Summary
Constructors Constructor Description MathTools()
-
Method Summary
Modifier and Type Method Description static Pair<java.lang.Double,java.lang.Double>
averageAndVariance(java.util.Collection<java.lang.Double> values)
Compute the average value and the variance of the given list of numbers.static java.lang.Integer
binomial(java.lang.Integer n, java.lang.Integer k)
This method computes "n choose k".static int
faculty(int i)
Computes the faculty of the given number.
-
-
-
Method Detail
-
binomial
public static java.lang.Integer binomial(java.lang.Integer n, java.lang.Integer k)
This method computes "n choose k". If n < 0 or k < 0 the result is defined to be 0.- Parameters:
n
- an integer.k
- an integer- Returns:
- the value of "n choose k".
-
faculty
public static int faculty(int i)
Computes the faculty of the given number.- Parameters:
i
- an integer.- Returns:
- the value 1*...*i or 1 if i==0.
-
averageAndVariance
public static Pair<java.lang.Double,java.lang.Double> averageAndVariance(java.util.Collection<java.lang.Double> values)
Compute the average value and the variance of the given list of numbers.- Parameters:
values
- some values- Returns:
- a pair of average value (first element) and variance (second element).
-
-