org.statcato.graph
Class StemAndLeafPlot
- java.lang.Object
-
- org.statcato.graph.StemAndLeafPlot
-
public class StemAndLeafPlot extends java.lang.ObjectA stem-and-leaf plot.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field and Description static booleanDEBUGDebug flag.booleandisplayEmptyStemA boolean variable indicating whether stems with no leaves should be displayed.
-
Constructor Summary
Constructors Constructor and Description StemAndLeafPlot(java.util.Vector<java.lang.Double> values, double u)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static doublecomputeCommonLeafUnit(java.util.Vector<java.lang.Double> units)Returns the common leaf unit that should be used for the given set of leaf units.static doublecomputeLeafUnit(double x)Computes and returns the proper leaf unit for the given number.static intgetLeaf(double value, double place)Returns the leaf of the given double value at the given leaf unit.static intgetLeafIndex(double value, double place)Returns the index of the starting location of the leaf in given data value.doublegetLeafUnits()Returns the leaf unit used in this stem-and-leaf plot.static doublegetStem(double value, double place)Returns the stem for the given data value given the leaf unit.static voidprintDebug(java.lang.String msg)Prints the given debug message to the standard output.java.lang.StringtoString()Returns an html formatted string of a table containing the stems and leaves.
-
-
-
Field Detail
-
DEBUG
public static boolean DEBUG
Debug flag.
-
displayEmptyStem
public boolean displayEmptyStem
A boolean variable indicating whether stems with no leaves should be displayed.
-
-
Constructor Detail
-
StemAndLeafPlot
public StemAndLeafPlot(java.util.Vector<java.lang.Double> values, double u)Constructor. The data values and the leaf unit are given.- Parameters:
values- vector of double valuesu- leaf unit (10^x where x is an integer, -1 if the leaf unit is not pre-determined)
-
-
Method Detail
-
toString
public java.lang.String toString()
Returns an html formatted string of a table containing the stems and leaves.- Overrides:
toStringin classjava.lang.Object- Returns:
- string of html code
-
getLeafUnits
public double getLeafUnits()
Returns the leaf unit used in this stem-and-leaf plot.- Returns:
- leaf unit (double)
-
getStem
public static double getStem(double value, double place)Returns the stem for the given data value given the leaf unit.- Parameters:
value- double valueplace- leaf unit (double)- Returns:
- stem (double)
-
getLeafIndex
public static int getLeafIndex(double value, double place)Returns the index of the starting location of the leaf in given data value.- Parameters:
value- double valueplace- leaf unit- Returns:
- integer index
-
getLeaf
public static int getLeaf(double value, double place)Returns the leaf of the given double value at the given leaf unit.- Parameters:
value- double valueplace- leaf unit- Returns:
- leaf (integer [0,9])
-
computeLeafUnit
public static double computeLeafUnit(double x)
Computes and returns the proper leaf unit for the given number. The leaf unit for a number is the place to the right of the leftmost non-zero digit.- Parameters:
x- a double value- Returns:
- the proper leaf unit for x
-
computeCommonLeafUnit
public static double computeCommonLeafUnit(java.util.Vector<java.lang.Double> units)
Returns the common leaf unit that should be used for the given set of leaf units. The maximum of the given leaf units is the common leaf unit.- Parameters:
units- vector of leaf units (double values)- Returns:
- common leaf unit that should be used for the given set of leaf units
-
printDebug
public static void printDebug(java.lang.String msg)
Prints the given debug message to the standard output.- Parameters:
msg- string
-
-
DMelt 3.0 © DataMelt by jWork.ORG