Class Helper
java.lang.Object
si.ijs.kt.clus.ext.semisupervised.Helper
Some handy functions
- Author:
- jurical
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringarrayToString(double[] array) Return the values of an array in a comma separated stringstatic StringarrayToString(double[] array, String sep) Return the values of an array in a string separatedsepstatic StringarrayToString(String[] array, String sep) Return the values of an array in a string separatedsepstatic StringarrayToString(IndiceValuePair[] array, String sep) Return the values of an array in a string separatedsepstatic doubleaverage(double[] values) Calculates average of an array of valuesstatic doubleaverageIgnoreZeros(double[] values) static double[]getArrayOfSecond(DoublesPair[] dpArrray) Return array containing just the second values of the DoublePairs arraystatic doublegetMean(double[] data) static doublegetStdDev(double[] data) corrected sample standard deviationstatic doublegetVariance(double[] data) static IndiceValuePair[]greatestKelements(double[] myArray, int K) Returns K greatest elements of an array, together with indicesstatic IndiceValuePair[]leastKelements(double[] myArray, int K) Returns K least elements of an array, together with indicesstatic doublemax(double[] values) Calculates maximum of an array of valuesstatic doublemedian(double[] data) static doublemin(double[] values) Calculates minimum of an array of valuesstatic voidprintArray(double[] array) static voidprintArray(DoublesPair[] array) Prints arraystatic doublestDevOpt(double[] a) Calculates standard deviation IMPORTANT: this implementation is buggy, it returns Double.NaN, when stdDev should be 0static doublesum(double[] values) Calculates sum of an array of values
-
Constructor Details
-
Helper
public Helper()
-
-
Method Details
-
average
public static double average(double[] values) Calculates average of an array of values -
averageIgnoreZeros
public static double averageIgnoreZeros(double[] values) -
min
public static double min(double[] values) Calculates minimum of an array of values -
sum
public static double sum(double[] values) Calculates sum of an array of values -
max
public static double max(double[] values) Calculates maximum of an array of values -
arrayToString
Return the values of an array in a comma separated string- Parameters:
array-
-
arrayToString
Return the values of an array in a string separatedsep- Parameters:
array-sep- separator
-
arrayToString
Return the values of an array in a string separatedsep- Parameters:
array-sep- separator
-
arrayToString
Return the values of an array in a string separatedsep- Parameters:
array-sep- separator
-
stDevOpt
public static double stDevOpt(double[] a) Calculates standard deviation IMPORTANT: this implementation is buggy, it returns Double.NaN, when stdDev should be 0 -
getArrayOfSecond
Return array containing just the second values of the DoublePairs array -
printArray
Prints array- Parameters:
array-
-
printArray
public static void printArray(double[] array) -
getMean
public static double getMean(double[] data) -
getVariance
public static double getVariance(double[] data) -
getStdDev
public static double getStdDev(double[] data) corrected sample standard deviation- Parameters:
data-
-
median
public static double median(double[] data) -
leastKelements
Returns K least elements of an array, together with indices- Parameters:
myArray- array may contain Double.NaN, such elements of arrray are ignoredK-- Returns:
- array of K least elements (index,value pairs) of an input array
-
greatestKelements
Returns K greatest elements of an array, together with indices- Parameters:
myArray-K-- Returns:
- array of K greatest elements (index,value pairs) of an input array
-