public class BasicMathFunctions extends Object
Constructor and Description |
---|
BasicMathFunctions() |
Modifier and Type | Method and Description |
---|---|
static Long |
factorial(Integer n)
Returns n! as a long.
|
static Long |
factorial(Integer n,
Integer k)
Returns n!/k!, null if it cannot fit in a long.
|
static Long |
getCombination(int k,
int n)
Returns the number of k-combinations in a set of n elements.
|
static double |
getCorrelation(ArrayList<Double> series1,
ArrayList<Double> series2)
Returns the population Pearson correlation r between series1 and series2.
|
static double |
getRobustCorrelation(ArrayList<Double> series1,
ArrayList<Double> series2)
Returns the population Pearson correlation r between series1 and series2.
|
static double |
log(double input,
double base)
Returns the log of the input in the desired base.
|
static double |
mad(ArrayList<Double> ratios)
Method estimating the median absolute deviation.
|
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 |
medianSorted(ArrayList<Double> input)
Method to estimate the median of a sorted list.
|
static double |
percentile(ArrayList<Double> input,
double percentile)
Returns the desired percentile in a given list of double.
|
static double |
percentile(double[] input,
double percentile)
Returns the desired percentile in a given array of double.
|
static double |
percentileSorted(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.
|
static double |
sum(ArrayList<Double> input)
Convenience method returning the sum of a list of doubles.
|
public static Long factorial(Integer n)
n
- a given integerpublic static Long factorial(Integer n, Integer k)
n
- a given integerk
- a given integerpublic static Long getCombination(int k, int n)
k
- the number of k-combinationsn
- the number of elementspublic static double median(double[] ratios)
ratios
- array of doublepublic static double median(ArrayList<Double> input)
input
- ArrayList of doublepublic static double medianSorted(ArrayList<Double> input)
input
- ArrayList of doublepublic static double percentile(double[] input, double percentile)
input
- the input arraypercentile
- the desired percentile. 0.01 returns the first
percentile. 0.5 returns the median.public static double percentile(ArrayList<Double> input, double percentile)
input
- the input listpercentile
- the desired percentile. 0.01 returns the first
percentile. 0.5 returns the median.public static double percentileSorted(ArrayList<Double> input, double percentile)
input
- the input listpercentile
- the desired percentile. 0.01 returns the first
percentile. 0.5 returns the median.public static double mad(double[] ratios)
ratios
- array of doublespublic static double mad(ArrayList<Double> ratios)
ratios
- array of doublespublic static double log(double input, double base)
input
- the inputbase
- the log basepublic static double std(ArrayList<Double> input)
input
- input listpublic static double mean(ArrayList<Double> input)
input
- input listpublic static double sum(ArrayList<Double> input)
input
- input listpublic static double getCorrelation(ArrayList<Double> series1, ArrayList<Double> series2)
series1
- first series to compareseries2
- second series to comparepublic static double getRobustCorrelation(ArrayList<Double> series1, ArrayList<Double> series2)
series1
- the first series to inspectseries2
- the second series to inspectCopyright © 2016. All rights reserved.