Class Helper

java.lang.Object
si.ijs.kt.clus.ext.semisupervised.Helper

public class Helper extends Object
Some handy functions
Author:
jurical
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    arrayToString(double[] array)
    Return the values of an array in a comma separated string
    static String
    arrayToString(double[] array, String sep)
    Return the values of an array in a string separated sep
    static String
    arrayToString(String[] array, String sep)
    Return the values of an array in a string separated sep
    static String
    Return the values of an array in a string separated sep
    static double
    average(double[] values)
    Calculates average of an array of values
    static double
    averageIgnoreZeros(double[] values)
     
    static double[]
    Return array containing just the second values of the DoublePairs array
    static double
    getMean(double[] data)
     
    static double
    getStdDev(double[] data)
    corrected sample standard deviation
    static double
    getVariance(double[] data)
     
    greatestKelements(double[] myArray, int K)
    Returns K greatest elements of an array, together with indices
    leastKelements(double[] myArray, int K)
    Returns K least elements of an array, together with indices
    static double
    max(double[] values)
    Calculates maximum of an array of values
    static double
    median(double[] data)
     
    static double
    min(double[] values)
    Calculates minimum of an array of values
    static void
    printArray(double[] array)
     
    static void
    Prints array
    static double
    stDevOpt(double[] a)
    Calculates standard deviation IMPORTANT: this implementation is buggy, it returns Double.NaN, when stdDev should be 0
    static double
    sum(double[] values)
    Calculates sum of an array of values

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static String arrayToString(double[] array)
      Return the values of an array in a comma separated string
      Parameters:
      array -
    • arrayToString

      public static String arrayToString(double[] array, String sep)
      Return the values of an array in a string separated sep
      Parameters:
      array -
      sep - separator
    • arrayToString

      public static String arrayToString(String[] array, String sep)
      Return the values of an array in a string separated sep
      Parameters:
      array -
      sep - separator
    • arrayToString

      public static String arrayToString(IndiceValuePair[] array, String sep)
      Return the values of an array in a string separated sep
      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

      public static double[] getArrayOfSecond(DoublesPair[] dpArrray)
      Return array containing just the second values of the DoublePairs array
    • printArray

      public static void printArray(DoublesPair[] array)
      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

      public static IndiceValuePair[] leastKelements(double[] myArray, int K)
      Returns K least elements of an array, together with indices
      Parameters:
      myArray - array may contain Double.NaN, such elements of arrray are ignored
      K -
      Returns:
      array of K least elements (index,value pairs) of an input array
    • greatestKelements

      public static IndiceValuePair[] greatestKelements(double[] myArray, int K)
      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