Class MathTools

java.lang.Object
org.tweetyproject.commons.util.MathTools

public class MathTools extends Object
This class contains some useful math tools.
Author:
Matthias Thimm
  • Constructor Details

    • MathTools

      public MathTools()
  • Method Details

    • binomial

      public static Integer binomial(Integer n, 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<Double,Double> averageAndVariance(Collection<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).