netkit.util
Class HistogramDiscrete

java.lang.Object
  extended by netkit.util.Histogram
      extended by netkit.util.HistogramDiscrete

public final class HistogramDiscrete
extends Histogram

This class represents a histogram on Node field values which have DISCRETE type. The histogram keeps track of unique values and a running of how many times each value appeared.

Author:
Kaveh R. Ghazi
See Also:
AttributeDiscrete, Node

Field Summary
 
Fields inherited from class netkit.util.Histogram
cMap
 
Constructor Summary
HistogramDiscrete(double[] values, AttributeDiscrete attribute)
          This constructor is a convenience for accepting all values without any minimum occurance.
HistogramDiscrete(double[] values, AttributeDiscrete attribute, int minOccurance)
          This constructor creates a histogram object given an array of values and an attribute type.
HistogramDiscrete(Edge[] edges, AttributeDiscrete attribute)
          This constructor is a convenience for accepting all edge values without any minimum occurance.
HistogramDiscrete(Edge[] edges, AttributeDiscrete attribute, int minOccurance)
          This constructor creates a histogram object given an array of edges and an attribute from which to get the values.
HistogramDiscrete(Node[] nodes, AttributeDiscrete attribute)
          This constructor is a convenience for accepting all node values without any minimum occurance.
HistogramDiscrete(Node[] nodes, AttributeDiscrete attribute, int minOccurance)
          This constructor creates a histogram object given an array of nodes and an attribute from which to get the values.
 
Method Summary
 AttributeDiscrete getAttribute()
          Gets the attribute associated with this histogram.
 int getMaxValue()
          Gets the maximum value stored in this object.
 double getMeanValue()
          Gets the mean (average) value of the values in this object.
 double getMedianValue()
          Gets the median value of the values in this object.
 int getMinValue()
          Gets the minimum value stored in this object.
 
Methods inherited from class netkit.util.Histogram
getCount, getDistribution, getMode, getSet, getTotalCount, main
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistogramDiscrete

public HistogramDiscrete(double[] values,
                         AttributeDiscrete attribute)
This constructor is a convenience for accepting all values without any minimum occurance.

Parameters:
values - the array of double values for this object.
attribute - the attribute describing the field type.

HistogramDiscrete

public HistogramDiscrete(double[] values,
                         AttributeDiscrete attribute,
                         int minOccurance)
This constructor creates a histogram object given an array of values and an attribute type. It also checks that values appear at least minOccurance times before including them.

Parameters:
values - the array of double values for this object.
attribute - the attribute describing the field type.
minOccurance - the minimum number of times a value must occur before being kept in this histogram.
Throws:
java.lang.RuntimeException - if minOccurance is less than 1.

HistogramDiscrete

public HistogramDiscrete(Node[] nodes,
                         AttributeDiscrete attribute)
This constructor is a convenience for accepting all node values without any minimum occurance.

Parameters:
nodes - the array of Nodes from which to get values.
attribute - the attribute describing which field in the Node to get values from.

HistogramDiscrete

public HistogramDiscrete(Edge[] edges,
                         AttributeDiscrete attribute)
This constructor is a convenience for accepting all edge values without any minimum occurance.

Parameters:
edges - the array of Edges from which to get values.
attribute - the attribute describing which field in the Node to get values from.

HistogramDiscrete

public HistogramDiscrete(Node[] nodes,
                         AttributeDiscrete attribute,
                         int minOccurance)
This constructor creates a histogram object given an array of nodes and an attribute from which to get the values. It also checks that values appear at least minOccurance times before including them.

Parameters:
nodes - the array of Nodes from which to get values.
attribute - the attribute describing the field in the Node to get values from.
minOccurance - the minimum number of times a value must occur before being kept in this histogram.
Throws:
java.lang.RuntimeException - if minOccurance is less than 1.

HistogramDiscrete

public HistogramDiscrete(Edge[] edges,
                         AttributeDiscrete attribute,
                         int minOccurance)
This constructor creates a histogram object given an array of edges and an attribute from which to get the values. Each edge counts the destination-node's attribute edge-weight times. It also checks that values appear at least minOccurance times before including them.

Parameters:
edges - the array of Edges from which to get values.
attribute - the attribute describing the field in the Node to get values from.
minOccurance - the minimum number of times a value must occur before being kept in this histogram.
Throws:
java.lang.RuntimeException - if minOccurance is less than 1.
Method Detail

getAttribute

public AttributeDiscrete getAttribute()
Gets the attribute associated with this histogram.

Returns:
the attribute associated with this histogram.

getMaxValue

public int getMaxValue()
Gets the maximum value stored in this object.

Returns:
the maximum value stored in this object.

getMinValue

public int getMinValue()
Gets the minimum value stored in this object.

Returns:
the minimum value stored in this object.

getMeanValue

public double getMeanValue()
Gets the mean (average) value of the values in this object. The mean is weighted by the count of each value.

Returns:
the mean (average) value of the values in this object.

getMedianValue

public double getMedianValue()
Gets the median value of the values in this object. The median is weighted by the count of each value.

Returns:
the median value of the values in this object.
Throws:
java.lang.RuntimeException - if there are no values in this object.