com.compomics.util.math
Class BasicMathFunctions

java.lang.Object
  extended by com.compomics.util.math.BasicMathFunctions

public class BasicMathFunctions
extends Object

Class used to perform basic mathematical functions.

Author:
Marc Vaudel

Constructor Summary
BasicMathFunctions()
           
 
Method Summary
static int factorial(int n)
          Returns n!
static double getCombination(int k, int n)
          Returns the number of k-combinations in a set of n elements.
static double mad(double[] ratios)
          Method estimating the median absolute deviation.
static double mean(ArrayList<Double> input)
          Convenience method returning the mean of a list of doubles.
static double median(ArrayList<Double> input)
          Method to estimate the median.
static double median(double[] ratios)
          Method to estimate the median.
static double percentile(ArrayList<Double> input, double percentile)
          Returns the desired percentile in a given list of double.
static double std(ArrayList<Double> input)
          Convenience method returning the standard deviation of a list of doubles.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicMathFunctions

public BasicMathFunctions()
Method Detail

factorial

public static int factorial(int n)
Returns n!

Parameters:
n - a given integer
Returns:
the corresponding factorial

getCombination

public static double getCombination(int k,
                                    int n)
Returns the number of k-combinations in a set of n elements.

Parameters:
k - the number of k-combinations
n - the number of elements
Returns:
the number of k-combinations in a set of n elements

median

public static double median(double[] ratios)
Method to estimate the median.

Parameters:
ratios - array of double
Returns:
median of the input

median

public static double median(ArrayList<Double> input)
Method to estimate the median.

Parameters:
input - ArrayList of double
Returns:
median of the input

percentile

public static double percentile(ArrayList<Double> input,
                                double percentile)
Returns the desired percentile in a given list of double. If the percentile is between two values a linear interpolation is done.

Parameters:
input - the input list
percentile - the desired percentile. 0.01 returns the first percentile. 0.5 returns the median.
Returns:
the desired percentile

mad

public static double mad(double[] ratios)
Method estimating the median absolute deviation.

Parameters:
ratios - array of doubles
Returns:
the mad of the input

std

public static double std(ArrayList<Double> input)
Convenience method returning the standard deviation of a list of doubles. Returns 0 if the list is null or of size < 2.

Parameters:
input - input list
Returns:
the corresponding standard deviation

mean

public static double mean(ArrayList<Double> input)
Convenience method returning the mean of a list of doubles.

Parameters:
input - input list
Returns:
the corresponding mean


Copyright © 2013. All Rights Reserved.