|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.utils.ToolBox
public class ToolBox
This class is a collection of methods which might be useful for the programmer.
| Nested Class Summary | |
|---|---|
static class |
ToolBox.TiedRanks
Handling of tied ranks in rank(double[], TiedRanks). |
| Constructor Summary | |
|---|---|
ToolBox()
|
|
| Method Summary | ||
|---|---|---|
static int |
getMaxIndex(double[] w)
Returns the index with maximal value in a double array. |
|
static int |
getMaxIndex(int start,
int end,
double[] w)
Returns the index with maximal value in a double array. |
|
static double[] |
getUniqueHueValues(int number)
Creates an array of hue values that can be used for the representation of probabilities. |
|
static double |
max(double... array)
This method returns the maximum of the elements of an array. |
|
static double |
max(int start,
int end,
double[] array)
This method returns the maximum of the elements of an array
between start and end. |
|
static double |
mean(int start,
int end,
double[] array)
This method returns the mean of the elements of an array
between start and end. |
|
static double |
median(double... array)
This method returns the median of the elements of array. |
|
static double |
median(int start,
int end,
double[] array)
This method returns the median of the elements of an array
between start and end. |
|
static double |
min(double... array)
This method returns the minimum of the elements of an array. |
|
static double |
min(int start,
int end,
double[] array)
This method returns the minimum of the elements of an array
between start and end. |
|
static int[] |
order(double[] values,
boolean ascending)
This method computes the order of the elements to obtain a sorted array. |
|
static
|
parseHashSet2IndexHashtable(HashSet<K> set)
This method converts a HashSet in a Hashtable with unique indices starting at 0. |
|
static double |
pearsonCorrelation(double[] v1,
double[] v2)
The method computes the Pearson correlation of two vectors. |
|
static double |
pearsonCorrelation(double[] v1,
double[] v2,
int off1,
int off2)
The method computes the Pearson correlation of two vectors beginning at specific offsets. |
|
static double |
pearsonCorrelation(double[] v1,
double[] v2,
int off1,
int off2,
int length)
The method computes the Pearson correlation of two vectors beginning at specific offsets and using a given number of entries. |
|
static double |
percentile(double[] array,
double percent)
Returns the percent percentile of the array, i.e.,
returns the element at percent*(array.length) of the sorted array. |
|
static double |
percentile(int start,
int end,
double[] array,
double percent)
Returns the percent percentile of the array between start and end, i.e.,
returns the element at percent*(end-start) of the sorted sub-array. |
|
static int[] |
rank(double[] values,
boolean sameRank)
Ranks the values in values, where the greatest value obtains the lowest rank. |
|
static int[] |
rank(double[] values,
ToolBox.TiedRanks ties)
Ranks the values in values, where the greatest value obtains the lowest rank. |
|
static double |
sd(int start,
int end,
double[] array)
This method returns the standard deviation of the elements of an array
between start and end. |
|
static void |
sortAlongWith(double[] arrayToBeSorted,
double[]... alongWith)
This method implements a sort algorithm on the array arrayToBeSorted. |
|
static double |
spearmanCorrelation(double[] v1,
double[] v2)
The method computes the Spearman correlation of two vectors. |
|
static double |
sum(double... array)
Computes the sum of the values in array |
|
static double |
sum(int start,
int end,
double[] array)
Computes the sum of the values in array starting at
start until end. |
|
static String |
toString(double[] array,
NumberFormat nf)
This methods returns a String representation of a double array using the specified NumberFormat. |
|
static double[][] |
transpose(double[][] sp)
Transpose a double matrix. |
|
static double |
weightPercentile(double[] array,
double percent)
Returns the element in the sorted variant of array (considered in descending order)
that yields percent of the cumulative value of array elements. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ToolBox()
| Method Detail |
|---|
public static <K> Hashtable<K,Integer> parseHashSet2IndexHashtable(HashSet<K> set)
HashSet in a Hashtable with unique indices starting at 0.
The indices are derived from the order of the Iterator of the HashSet.
K - the type of the keysset - the set of keys
Hashtable with keys and unique indices starting at 0public static double max(double... array)
array.
array - the array of values
public static double min(double... array)
array.
array - the array of values
public static double max(int start,
int end,
double[] array)
array
between start and end.
start - start position (inclusive)end - end position (exclusive)array - the array of values
public static double min(int start,
int end,
double[] array)
array
between start and end.
start - start position (inclusive)end - end position (exclusive)array - the array of values
public static final int getMaxIndex(double[] w)
double array.
w - the given double array
public static final int getMaxIndex(int start,
int end,
double[] w)
double array.
w - the given double arraystart - start position (inclusive)end - end position (exclusive)
public static double median(double... array)
array.
array - the array of values
public static double median(int start,
int end,
double[] array)
array
between start and end.
start - start position (inclusive)end - end position (exclusive)array - the array of values
public static double mean(int start,
int end,
double[] array)
array
between start and end.
start - start position (inclusive)end - end position (exclusive)array - the array of values
public static double sd(int start,
int end,
double[] array)
array
between start and end.
start - start position (inclusive)end - end position (exclusive)array - the array of values
public static double percentile(double[] array,
double percent)
percent percentile of the array, i.e.,
returns the element at percent*(array.length) of the sorted array.
array - the arraypercent - the percentage
public static double percentile(int start,
int end,
double[] array,
double percent)
percent percentile of the array between start and end, i.e.,
returns the element at percent*(end-start) of the sorted sub-array.
start - the first index to considerend - the end index (exclusive)array - the arraypercent - the percentage
public static double weightPercentile(double[] array,
double percent)
array (considered in descending order)
that yields percent of the cumulative value of array elements.
array - the arraypercent - the percentage
public static final int[] rank(double[] values,
boolean sameRank)
values, where the greatest value obtains the lowest rank.
The boolean sameRank allows to decide whether tied values should obtain the same rank.
values - the valuessameRank - a switch whether tied values obtain the same rank.
public static final int[] order(double[] values,
boolean ascending)
values - the arrayascending - a switch whether the array should be sorted ascending or descending
public static final int[] rank(double[] values,
ToolBox.TiedRanks ties)
values, where the greatest value obtains the lowest rank.
The enum ties allows to choose how tied ranks are handled.
values - the valuesties - a switch how to handle tied ranks
ToolBox.TiedRanks
public static double spearmanCorrelation(double[] v1,
double[] v2)
throws Exception
v1 - the first vectorv2 - the second vector
Exception - if the vectors have different length
public static double pearsonCorrelation(double[] v1,
double[] v2)
throws Exception
v1 - the first vectorv2 - the second vector
Exception - if the vectors have different length
public static double pearsonCorrelation(double[] v1,
double[] v2,
int off1,
int off2)
throws Exception
v1 - the first vectorv2 - the second vectoroff1 - the offset for the first vectoroff2 - the offset for the second vector
Exception - if the vectors have different length
public static double pearsonCorrelation(double[] v1,
double[] v2,
int off1,
int off2,
int length)
throws Exception
v1 - the first vectorv2 - the second vectoroff1 - the offset for the first vectoroff2 - the offset for the second vectorlength - the number of elements to be used for computing the correlation
Exception - if the vectors have different lengthpublic static double sum(double... array)
array
array - the array
array
public static double sum(int start,
int end,
double[] array)
array starting at
start until end.
start - the index of the first element in the sum (inclusive)end - the end index (exclusive)array - the array
array from start to end
public static double[][] transpose(double[][] sp)
throws Exception
double matrix.
sp - the array
Exception - if sp is no matrixpublic static double[] getUniqueHueValues(int number)
number - the number of colors
public static void sortAlongWith(double[] arrayToBeSorted,
double[]... alongWith)
arrayToBeSorted.
However, the entries of the array alongWith are reordered in the same way asarrayToBeSorted.
arrayToBeSorted - the array to be sortedalongWith - a series of arrays that is in the same way reordered as arrayToBeSorted.Arrays.sort(Object[], Comparator),
DoubleArrayComparator
public static String toString(double[] array,
NumberFormat nf)
String representation of a double array using the specified NumberFormat.
array - the array to be representednf - the NumberFormat to be used
String representation
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||