|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.ed.inf.utils.Utils
public class Utils
Various utilities to manipulate vectors of numbers, get a timestamp etc.
| Constructor Summary | |
|---|---|
Utils()
|
|
| Method Summary | |
|---|---|
static double |
calcAverage(double[] values)
Calculates the average of the numbers in an array (from web http://forum.java.sun.com/, author JosAH) |
static double |
calcStandardDeviation(double[] values)
Calculates the standard deviation of the elements in an array as root of the variance = [sum( x(i) - mean)^2 )] / (n-1), where x(i) is the ith element, m the mean, n the number of elements |
static java.util.TreeSet<java.lang.Double> |
getDoubleIntervals(java.lang.Double min,
java.lang.Double max,
java.lang.Double percentOfIncrement)
|
static boolean |
getFlag(java.lang.String opt,
java.lang.String[] options)
|
static java.util.TreeSet |
getIncrements(java.lang.Object min,
java.lang.Object max,
java.lang.Double percentageOfIncrement)
Returns a vector of numbers, starting from a minimum value, with incremental increases until the maximum value. |
static java.util.TreeSet<java.lang.Integer> |
getIncrementsFromRange(java.lang.Integer range,
java.lang.Double percentageOfIncrement)
Returns a set of increments. |
static java.util.TreeSet<java.lang.Integer> |
getIntegerIntervals(java.lang.Integer min,
java.lang.Integer max,
java.lang.Double percentageOfIncrement)
Returns a vector of numbers, starting from a minimum value, with incremental increases until the maximum value. |
static void |
getJavaSystemProperties()
Gets the Java system properties |
static java.lang.String |
getOption(java.lang.String opt,
java.lang.String[] options)
getOption(String opt, String[] options) gets an option value out of a list of options |
static java.util.TreeSet<java.lang.String> |
getSimpleSerie(java.lang.Double min,
java.lang.Double increment,
int iterations)
Gets a series of doubles from a min incrementing by a given increment for a number of iterations |
static void |
main(java.lang.String[] argv)
Main method for testing |
static java.util.Properties |
readLocalProperties(java.lang.String resourceName)
Reads properties that inherit from three locations. |
static java.util.Properties |
readProperties(java.lang.String propertiesFilePath)
Reads properties Code adapted from Weka: http://www.cs.waikato.ac.nz/ml/weka/ Ian H. |
static double |
roundDouble(double targetDouble,
int decimalPlace)
Rounds a number to just n decimal digits |
static java.util.TreeSet<java.lang.String> |
setFromObjectsToString(java.util.TreeSet<java.lang.Object> set)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Utils()
| Method Detail |
|---|
public static double calcAverage(double[] values)
public static double calcStandardDeviation(double[] values)
public static java.util.TreeSet<java.lang.Double> getDoubleIntervals(java.lang.Double min,
java.lang.Double max,
java.lang.Double percentOfIncrement)
public static boolean getFlag(java.lang.String opt,
java.lang.String[] options)
public static java.util.TreeSet getIncrements(java.lang.Object min,
java.lang.Object max,
java.lang.Double percentageOfIncrement)
min - the minimum number valuemax - the maximum number valuepercentageOfIncrement - the increment as percentage of (maximum - minimum) value (the
actual increment value has to be >= 1 !)
public static java.util.TreeSet<java.lang.Integer> getIncrementsFromRange(java.lang.Integer range,
java.lang.Double percentageOfIncrement)
range - percentageOfIncrement -
public static java.util.TreeSet<java.lang.Integer> getIntegerIntervals(java.lang.Integer min,
java.lang.Integer max,
java.lang.Double percentageOfIncrement)
min - the minimum number valuemax - the maximum number valuepercentageOfIncrement - the increment as percentage of (maximum - minimum) value
public static void getJavaSystemProperties()
public static java.lang.String getOption(java.lang.String opt,
java.lang.String[] options)
opt - the option that needs to be extracted (e.g. -x)options - list of options (e.g. -x 10 -y name)
public static java.util.TreeSet<java.lang.String> getSimpleSerie(java.lang.Double min,
java.lang.Double increment,
int iterations)
min - the starting pointincrement - the incrementiterations - the number of repetitions
public static void main(java.lang.String[] argv)
throws java.lang.Exception
argv -
java.lang.Exception
public static java.util.Properties readLocalProperties(java.lang.String resourceName)
throws java.lang.Exception
resourceName - the location of the resource that should be loaded. e.g.:
"weka/core/Utils.props". (The use of hardcoded forward slashes
here is OK - see jdk1.1/docs/guide/misc/resources.html) This
routine will also look for the file (in this case)
"Utils.props" in the users home directory and the current
directory.
java.lang.Exception - if no default properties are defined, or if an error
occurs reading the properties files.
public static java.util.Properties readProperties(java.lang.String propertiesFilePath)
throws java.lang.Exception
java.lang.Exception - if no default properties are defined, or if an error
occurs reading the properties files.
public static double roundDouble(double targetDouble,
int decimalPlace)
targetDouble - the number to be roundeddecimalPlace - the number of digits to be left right of the decimal dot
public static java.util.TreeSet<java.lang.String> setFromObjectsToString(java.util.TreeSet<java.lang.Object> set)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||