Class PSquarePercentile.Markers

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int HIGH
      High marker index
      private int k
      Kth cell belonging to [1-5] of the markerArray.
      private static int LOW
      Low marker index
      private PSquarePercentile.Marker[] 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)
      private static long serialVersionUID
      Serial version id
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Markers​(java.util.List<java.lang.Double> initialFive, double p)
      Constructor
      private Markers​(PSquarePercentile.Marker[] theMarkerArray)
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void adjustHeightsOfMarkers()
      Adjust marker heights by setting quantile estimates to middle markers.
      java.lang.Object clone()
      A clone function to clone the current instance.
      private static PSquarePercentile.Marker[] createMarkerArray​(java.util.List<java.lang.Double> initialFive, double p)
      Creates a marker array using initial five elements and a quantile
      boolean equals​(java.lang.Object o)
      .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 Marker
      private int findCellAndUpdateMinMax​(double observation)
      Finds the cell where the input observation / value fits.
      double getPercentileValue()
      Returns the percentile computed thus far.
      int hashCode()
      double height​(int markerIndex)
      Return marker height given index
      private void incrementPositions​(int d, int startIndex, int endIndex)
      Increment positions by d.
      double processDataPoint​(double inputDataPoint)
      Process a data point
      private void readObject​(java.io.ObjectInputStream anInputStream)
      Sets previous and next markers after default read is done.
      java.lang.String toString()
      Returns string representation of the Marker array.
      private void updateDesiredPositions()
      Desired positions incremented by bucket width.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Serial version id
        See Also:
        Constant Field Values
      • markerArray

        private final PSquarePercentile.Marker[] 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 k
        Kth cell belonging to [1-5] of the markerArray. No need for this to be serialized
    • Constructor Detail

      • Markers

        private Markers​(PSquarePercentile.Marker[] theMarkerArray)
        Constructor
        Parameters:
        theMarkerArray - marker array to be used
      • Markers

        private Markers​(java.util.List<java.lang.Double> initialFive,
                        double p)
        Constructor
        Parameters:
        initialFive - elements required to build Marker
        p - quantile required to be computed
    • Method Detail

      • createMarkerArray

        private static PSquarePercentile.Marker[] createMarkerArray​(java.util.List<java.lang.Double> initialFive,
                                                                    double p)
        Creates a marker array using initial five elements and a quantile
        Parameters:
        initialFive - list of initial five elements
        p - the pth quantile
        Returns:
        Marker array
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        .This equals method basically checks for marker array to be deep equals.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - is the other object
        Returns:
        true if the object compares with this object are equivalent
      • processDataPoint

        public double processDataPoint​(double inputDataPoint)
        Process a data point
        Specified by:
        processDataPoint in interface PSquarePercentile.PSquareMarkers
        Parameters:
        inputDataPoint - is the data point passed
        Returns:
        computed percentile
      • 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 interface PSquarePercentile.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 position
        startIndex - start index of the marker array
        endIndex - 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

        private void readObject​(java.io.ObjectInputStream anInputStream)
                         throws java.lang.ClassNotFoundException,
                                java.io.IOException
        Sets previous and next markers after default read is done.
        Parameters:
        anInputStream - the input stream to be deserialized
        Throws:
        java.lang.ClassNotFoundException - thrown when a desired class not found
        java.io.IOException - thrown due to any io errors
      • height

        public double height​(int markerIndex)
        Return marker height given index
        Specified by:
        height in interface PSquarePercentile.PSquareMarkers
        Parameters:
        markerIndex - index of marker within (1,6)
        Returns:
        marker height
      • clone

        public java.lang.Object 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 interface PSquarePercentile.PSquareMarkers
        Overrides:
        clone in class java.lang.Object
        Returns:
        cloned object
      • toString

        public java.lang.String toString()
        Returns string representation of the Marker array.
        Overrides:
        toString in class java.lang.Object
        Returns:
        Markers as a string