Class PSquarePercentile.Markers
java.lang.Object
org.apache.commons.math3.stat.descriptive.rank.PSquarePercentile.Markers
- All Implemented Interfaces:
Serializable
,Cloneable
,PSquarePercentile.PSquareMarkers
- Enclosing class:
PSquarePercentile
private static class PSquarePercentile.Markers
extends Object
implements PSquarePercentile.PSquareMarkers, Serializable
Markers is an encapsulation of the five markers/buckets as indicated in
the original works.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
High marker indexprivate int
Kth cell belonging to [1-5] of the markerArray.private static final int
Low marker indexprivate final PSquarePercentile.Marker[]
Array of 5+1 Markers (The first marker is dummy just so we can match the rest of indexes [1-5] indicated in the original works which follows unit based index)private static final long
Serial version id -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Constructorprivate
Markers
(PSquarePercentile.Marker[] theMarkerArray) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Adjust marker heights by setting quantile estimates to middle markers.clone()
A clone function to clone the current instance.private static PSquarePercentile.Marker[]
createMarkerArray
(List<Double> initialFive, double p) Creates a marker array using initial five elements and a quantileboolean
.This equals method basically checks for marker array to be deep equals.double
estimate
(int index) An Estimate of the percentile value of a given Markerprivate int
findCellAndUpdateMinMax
(double observation) Finds the cell where the input observation / value fits.double
Returns the percentile computed thus far.int
hashCode()
double
height
(int markerIndex) Return marker height given indexprivate void
incrementPositions
(int d, int startIndex, int endIndex) Increment positions by d.double
processDataPoint
(double inputDataPoint) Process a data pointprivate void
readObject
(ObjectInputStream anInputStream) Sets previous and next markers after default read is done.toString()
Returns string representation of the Marker array.private void
Desired positions incremented by bucket width.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial version id- See Also:
-
LOW
private static final int LOWLow marker index- See Also:
-
HIGH
private static final int HIGHHigh marker index- See Also:
-
markerArray
Array of 5+1 Markers (The first marker is dummy just so we can match the rest of indexes [1-5] indicated in the original works which follows unit based index) -
k
private transient int kKth cell belonging to [1-5] of the markerArray. No need for this to be serialized
-
-
Constructor Details
-
Markers
Constructor- Parameters:
theMarkerArray
- marker array to be used
-
Markers
Constructor- Parameters:
initialFive
- elements required to build Markerp
- quantile required to be computed
-
-
Method Details
-
createMarkerArray
Creates a marker array using initial five elements and a quantile- Parameters:
initialFive
- list of initial five elementsp
- the pth quantile- Returns:
- Marker array
-
hashCode
public int hashCode() -
equals
.This equals method basically checks for marker array to be deep equals. -
processDataPoint
public double processDataPoint(double inputDataPoint) Process a data point- Specified by:
processDataPoint
in interfacePSquarePercentile.PSquareMarkers
- Parameters:
inputDataPoint
- is the data point passed- Returns:
- computed percentile
-
getPercentileValue
public double getPercentileValue()Returns the percentile computed thus far.- Specified by:
getPercentileValue
in interfacePSquarePercentile.PSquareMarkers
- Returns:
- height of mid point marker
-
findCellAndUpdateMinMax
private int findCellAndUpdateMinMax(double observation) Finds the cell where the input observation / value fits.- Parameters:
observation
- the input value to be checked for- Returns:
- kth cell (of the markers ranging from 1-5) where observed sample fits
-
adjustHeightsOfMarkers
private void adjustHeightsOfMarkers()Adjust marker heights by setting quantile estimates to middle markers. -
estimate
public double estimate(int index) An Estimate of the percentile value of a given Marker- Specified by:
estimate
in interfacePSquarePercentile.PSquareMarkers
- Parameters:
index
- the marker's index in the array of markers- Returns:
- percentile estimate
-
incrementPositions
private void incrementPositions(int d, int startIndex, int endIndex) Increment positions by d. Refer to algorithm paper for the definition of d.- Parameters:
d
- The increment value for the positionstartIndex
- start index of the marker arrayendIndex
- end index of the marker array
-
updateDesiredPositions
private void updateDesiredPositions()Desired positions incremented by bucket width. The bucket width is basically the desired increments. -
readObject
Sets previous and next markers after default read is done.- Parameters:
anInputStream
- the input stream to be deserialized- Throws:
ClassNotFoundException
- thrown when a desired class not foundIOException
- thrown due to any io errors
-
height
public double height(int markerIndex) Return marker height given index- Specified by:
height
in interfacePSquarePercentile.PSquareMarkers
- Parameters:
markerIndex
- index of marker within (1,6)- Returns:
- marker height
-
clone
A clone function to clone the current instance. It's created as an interface method as well for convenience though Cloneable is just a marker interface..Clone Markers- Specified by:
clone
in interfacePSquarePercentile.PSquareMarkers
- Overrides:
clone
in classObject
- Returns:
- cloned object
-
toString
Returns string representation of the Marker array.
-