de.invation.code.toval.statistic.StochasticUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TOVAL Show documentation
Show all versions of TOVAL Show documentation
TOVAL comprises a set of java classes for common programming issues. It includes utils for arrays, lists, sets and collections for convenient handling and modification, but also support for mathematic definitions concerning logic (clauses + resolution) together with some algorithms for permutations, powersets and resolution. Additionally it contains a number of types for multisets, matrices with object keys and much more.
The newest version!
package de.invation.code.toval.statistic;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
public class StochasticUtils {
//------EXPECTATION----------------------------------------------------------------------------------------
public static double getExpectation(Collection values) {
return new Observation(values).getExpectation();
}
//------MOMENTS--------------------------------------------------------------------------------------------
public static double getMoment(Collection values, int degree){
return getMoments(values, Arrays.asList(degree)).get(degree);
}
public static HashMap getMoments(Collection values, Collection degrees){
Observation o = new Observation(values);
o.setMomentDegrees(degrees);
return o.getMoments();
}
//------TRANSFORMATION--------------------------------------------------------------------------------------
//------AVERAGES--------------------------------------------------------------------------------------------
public static double getAverage(Collection values, AVERAGE_TYPE type) {
switch(type) {
case ARITHMETIC:
double sum = 0.0;
for(T t: values) {
sum += t.doubleValue();
}
return sum/values.size();
default: throw new IllegalArgumentException("\""+type+"\" is not a valid verage-type!");
}
}
public enum AVERAGE_TYPE {ARITHMETIC}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy