76 lines
1.8 KiB
Java
Executable File
76 lines
1.8 KiB
Java
Executable File
/*
|
|
|
|
* def stats(self,r):
|
|
#returns the average, standard deviation, and min of a sequence
|
|
tot = sum(r)
|
|
ave = tot/len(r)
|
|
sdsq = sum([(i-ave)**2 for i in r])
|
|
s = list(r)
|
|
s.sort()
|
|
#median = s[len(s)//2]
|
|
return ave, (sdsq/(len(r)-1 or 1))**.5
|
|
|
|
def zscore(self,pop_mean,pop_std,raw_goid):
|
|
return (raw_goid - pop_mean)/pop_std
|
|
*/
|
|
|
|
/**
|
|
*
|
|
* @author DTian
|
|
*/
|
|
public class Stats {
|
|
|
|
/**
|
|
*
|
|
* @param data the double array
|
|
* @return the stand deviation of the array
|
|
*/
|
|
public static double getStdDev(double[] data) {
|
|
double result = 0.0;
|
|
double ave = getMean(data);
|
|
for (double d : data) {
|
|
result += Math.pow((d-ave), 2);
|
|
}
|
|
if (data.length>1) {
|
|
return Math.sqrt(result/(data.length-1));
|
|
} else {
|
|
return Math.sqrt(result/1);
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param data the double array
|
|
* @return the mean of the double array.
|
|
*/
|
|
public static double getMean(double[] data) {
|
|
double result = 0.0;
|
|
for (double d : data) {
|
|
result += d;
|
|
}
|
|
return (result/data.length);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param size the size of ori cluster File
|
|
* @return the mean of the double array.
|
|
*/
|
|
public static double getMeanFromFunc(int size) {
|
|
return ( -4.8616 + 71.1806/Math.pow(size, 0.33511));
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param size the size of ori cluster File
|
|
* @return the mean of the double array.
|
|
*/
|
|
public static double getStdDevFromFunc(int size) {
|
|
return ( -0.04943 + 56.634/Math.pow(size, 0.89384));
|
|
}
|
|
|
|
public static double getZscore(double popMean, double popStd, double rawGoid) {
|
|
return (rawGoid - popMean)/popStd;
|
|
}
|
|
}
|