public class Distribution
extends java.lang.Object
Distribution consists of:
Constructor and Description |
---|
Distribution(Distribution aDistr)
Constructs Distribution from another Distribution.
|
Distribution(double aCum,
double[] aDistr)
Constructs Distribution from aCum/aDistr.
|
Distribution(int aSize)
Constructs Distribution of given size.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Distribution aDistr) |
void |
add(int index)
Increment value at index by 1.0.
|
void |
add(int index,
double val)
Increment value at index by val.
|
void |
add(int index,
double val,
double cum)
Increment value at index by val and cumulative by cum.
|
double |
average()
Calculate the average of distribution values.
|
double |
avgIndex()
Calculate the average index of distribution values.
|
void |
clear()
Clear distribution.
|
void |
divBy(double by)
Divide all elements and cumulative by by.
|
void |
full()
Fully populate distribution.
|
int |
getCount()
Count the number of non-zero elements.
|
double |
getCumulative()
Get cumulative value
|
int[] |
getSet()
Represent distribution with a set of values.
|
int |
getSingle()
Get a single value represented by distribution.
|
double |
getValue(int index)
Get distribution value at index.
|
void |
increment()
Increment distribution size by one.
|
double |
max()
Calculate the maximum of distribution values.
|
void |
mulBy(double by)
Multiply all elements and cumulative by by.
|
void |
normalize()
Normalize distribution by dividing all elements by cumulative.
|
void |
normalize(double n)
Normalize distribution by dividing all elements by n and setting
cumulative to 1.0.
|
void |
normalizeMax()
Normalize distribution so that max()==1.0.
|
void |
normalizeSet()
Convert distribution to a set by setting all non-zero elements and
cumulative to 1.0.
|
void |
normalizeSum()
Normalize distribution so that sum()==1.0.
|
void |
setCumulative(double aCumul)
Set cumulative.
|
void |
setSet(int[] set)
Convert a set into distribution.
|
void |
setSingle(int val)
Set the distribution to single value.
|
void |
setValue(int index,
double val)
Set distribution value at index to val.
|
int |
size()
Get distribution size.
|
double |
sum()
Calculate the sum of distribution values.
|
double |
sumDiv()
Calculate sum() divided by cumulative.
|
double |
sumMul()
Calculate weighted sum.
|
java.lang.String |
toString()
Represent distribution with a short string.
|
void |
uniform()
Create a uniform distribution with respect to the number of values.
|
public Distribution(int aSize)
aSize
- Initial length of distribution.public Distribution(double aCum, double[] aDistr)
aCum
- Initial cumulative value.aDistr
- Initial distribution.public Distribution(Distribution aDistr)
aDistr
- Other Distribution.public int size()
public double getCumulative()
public void setCumulative(double aCumul)
aCumul
- New cumulative vaue.public double getValue(int index)
index
- public void setValue(int index, double val)
index
- val
- public void clear()
public void full()
public void uniform()
public int getSingle()
public void setSingle(int val)
val
- public int getCount()
public int[] getSet()
public void setSet(int[] set)
set
- int[] containing indices of distribution elements whose values
are set to 1.o. Cumulative is also set to 1.0.public double sum()
public double max()
public double average()
public double avgIndex()
public double sumMul()
public double sumDiv()
public void add(Distribution aDistr)
public void add(int index, double val, double cum)
index
- Element index.val
- Value increment.cum
- Cumulative increment.public void add(int index, double val)
index
- Element index.val
- Value increment.public void add(int index)
index
- Element index.public void divBy(double by)
by
- public void mulBy(double by)
by
- public void normalize(double n)
n
- Divisor.public void normalize()
public void normalizeSum()
public void normalizeMax()
public void normalizeSet()
public void increment()
public java.lang.String toString()
toString
in class java.lang.Object