|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgr.demokritos.iit.conceptualIndex.structs.Distribution
public class Distribution
Represents a ditribution of values, either in terms of a simple histogram, or in terms of a probability distribution. Also provides methods for distribution normalization , comparison and other useful functions.
Constructor Summary | |
---|---|
Distribution()
Creates a new instance of Distribution |
|
Distribution(java.util.TreeMap<java.lang.Object,java.lang.Double> tm)
Creates a new instance of Distribution, given a corresponding TreeMap . |
Method Summary | |
---|---|
Distribution |
addTo(Distribution dOther)
Creates a new distribution containing the sum of values of the given distribution and a second distribution. |
java.util.TreeMap |
asTreeMap()
Returns the underlying TreeMap structure. |
double |
average(boolean bOnlyValueAverage)
Calculates the average value of the distribution. |
double |
calcSumSquaredErrorFrom(Distribution dOther)
|
double |
calcTotalValues()
Calculates the sum of all the values in the distribution. |
double |
compareDistributions(Distribution d1,
Distribution d2)
Use default comparison between d1 and d2. |
java.lang.Object |
getKeyOfMaxValue()
Looks up the key corresponding to the maximum value of the distribution. |
java.lang.Object |
getNextResult()
Returns a random key using this probability distribution. |
Distribution |
getProbabilityDistribution()
Creates a new probability distribution, corresponding to the occurences of the features appearing in this distribution. |
double |
getValue(java.lang.Object oKey)
Looks up the value of a selected key, or zero if the key has no value. |
void |
increaseValue(java.lang.Object oXValue,
double dYValue)
Increases the value of a selected key by a quantity. |
void |
invertProbability()
Inverts the probabilities of this distribution. |
static void |
main(java.lang.String[] args)
Testing function. |
double |
maxValue()
Looks up the maximum value appearing in the distribution. |
double |
minValue()
Looks up the minimum value appearing in the distribution. |
void |
normalize()
Normalizes the values of the distribution to the range [0,1] |
void |
normalizeTo(double dNewMax)
Normalizes the values of the distribution to a range of numbers between zero (0) and a selected value. |
void |
normalizeToSum()
Normalizes the values of the distribution to the sum of values, resolving to a probability distribution, as the sum of the new distribution will amount to 1. |
void |
setValue(java.lang.Object oXValue,
double dYValue)
Sets the value of a selected key. |
double |
similarityTo(Distribution dOther)
Calculates the degree of similarity between two distributions. |
double |
standardDeviation(boolean bOnlyValue)
Calculates the standard deviation (square root of the variance) of the distribution, either for the values only, or taking into account the keys. |
double |
sumOfValues()
Calculates the sum of values over all distribution points. |
java.lang.String |
toString()
Composes a string representation of this distribution, referring only to non-zero elements. |
double |
variance(boolean bOnlyValue)
Calculates the variance of the distribution, either for the values only, or taking into account the keys. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Distribution()
public Distribution(java.util.TreeMap<java.lang.Object,java.lang.Double> tm)
TreeMap
. The TreeMap should contain
Method Detail |
---|
public double getValue(java.lang.Object oKey)
oKey
- The key to look up.
public void setValue(java.lang.Object oXValue, double dYValue)
oXValue
- The key to use. The key can either be a double number or an object.dYValue
- The value to apply to the selected key.public void increaseValue(java.lang.Object oXValue, double dYValue)
oXValue
- The key to use. The key can either be a double number or an object.dYValue
- The value by which to increase the selected key value.public java.lang.String toString()
toString
in class java.lang.Object
public java.util.TreeMap asTreeMap()
TreeMap
structure.
public double similarityTo(Distribution dOther)
dOther
- The distribution to compare to.
public double calcTotalValues()
public void normalizeTo(double dNewMax)
dNewMax
- The new maximum value after the transformation.public void normalize()
public void normalizeToSum()
public double sumOfValues()
public Distribution getProbabilityDistribution()
public double average(boolean bOnlyValueAverage)
bOnlyValueAverage
- If true, then only the value average is computed, otherwise
the expected value is calculated, taking into account the keys (which are supposed to be
Double
objects)
public double maxValue()
public double minValue()
public double variance(boolean bOnlyValue)
bOnlyValue
- If true, then only the value variance is computed, otherwise
the variance is calculated taking into account the keys (which are supposed to be
Double
objects).
public double standardDeviation(boolean bOnlyValue)
bOnlyValue
- If true, then only the value standard deviation is computed, otherwise
the standard deviation is calculated taking into account the keys (which are supposed to be
Double
objects).
public java.lang.Object getKeyOfMaxValue()
public void invertProbability()
public java.lang.Object getNextResult()
public static void main(java.lang.String[] args)
public double calcSumSquaredErrorFrom(Distribution dOther)
public Distribution addTo(Distribution dOther)
dOther
- The other distribution.
public double compareDistributions(Distribution d1, Distribution d2)
compareDistributions
in interface IDistributionComparisonListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |