Class PSquarePercentile

    • Field Detail

      • PSQUARE_CONSTANT

        private static final int PSQUARE_CONSTANT
        The maximum array size used for psquare algorithm
        See Also:
        Constant Field Values
      • DEFAULT_QUANTILE_DESIRED

        private static final double DEFAULT_QUANTILE_DESIRED
        A Default quantile needed in case if user prefers to use default no argument constructor.
        See Also:
        Constant Field Values
      • DECIMAL_FORMAT

        private static final java.text.DecimalFormat DECIMAL_FORMAT
        A decimal formatter for print convenience
      • initialFive

        private final java.util.List<java.lang.Double> initialFive
        Initial list of 5 numbers corresponding to 5 markers. NOTE:watch out for the add methods that are overloaded
      • quantile

        private final double quantile
        The quantile needed should be in range of 0-1. The constructor PSquarePercentile(double) ensures that passed in percentile is divided by 100.
      • lastObservation

        private transient double lastObservation
        lastObservation is the last observation value/input sample. No need to serialize
      • pValue

        private double pValue
        Computed p value (i,e percentile value of data set hither to received)
      • countOfObservations

        private long countOfObservations
        Counter to count the values/observations accepted into this data set
    • Constructor Detail

      • PSquarePercentile

        public PSquarePercentile​(double p)
        Constructs a PSquarePercentile with the specific percentile value.
        Parameters:
        p - the percentile
        Throws:
        OutOfRangeException - if p is not greater than 0 and less than or equal to 100
      • PSquarePercentile

        PSquarePercentile()
        Default constructor that assumes a default quantile needed
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Returns true iff o is a PSquarePercentile returning the same values as this for getResult() and getN() and also having equal markers
        Overrides:
        equals in class AbstractStorelessUnivariateStatistic
        Parameters:
        o - object to compare
        Returns:
        true if o is a PSquarePercentile with equivalent internal state
      • increment

        public void increment​(double observation)
        Updates the internal state of the statistic to reflect the addition of the new value.The internal state updated due to the new value in this context is basically of the marker positions and computation of the approximate quantile.
        Specified by:
        increment in interface StorelessUnivariateStatistic
        Specified by:
        increment in class AbstractStorelessUnivariateStatistic
        Parameters:
        observation - the observation currently being added.
      • toString

        public java.lang.String toString()
        Returns a string containing the last observation, the current estimate of the quantile and all markers.
        Overrides:
        toString in class java.lang.Object
        Returns:
        string representation of state data
      • getN

        public long getN()
        Returns the number of values that have been added.
        Specified by:
        getN in interface StorelessUnivariateStatistic
        Returns:
        the number of values.
      • quantile

        public double quantile()
        Returns the quantile estimated by this statistic in the range [0.0-1.0]
        Returns:
        quantile estimated by getResult()
      • maximum

        private double maximum()
        Returns:
        maximum in the data set added to this statistic
      • minimum

        private double minimum()
        Returns:
        minimum in the data set added to this statistic
      • newMarkers

        public static PSquarePercentile.PSquareMarkers newMarkers​(java.util.List<java.lang.Double> initialFive,
                                                                  double p)
        A creation method to build Markers
        Parameters:
        initialFive - list of initial five elements
        p - the quantile desired
        Returns:
        an instance of PSquareMarkers