/** * {@inheritDoc}.Clone Markers * * @return cloned object */ @Override public Object clone() { return new Markers(new Marker[] { new Marker(), (Marker) markerArray[1].clone(), (Marker) markerArray[2].clone(), (Marker) markerArray[3].clone(), (Marker) markerArray[4].clone(), (Marker) markerArray[5].clone() }); }
/** * Process a data point * * @param inputDataPoint is the data point passed * @return computed percentile */ public double processDataPoint(final double inputDataPoint) { // 1. Find cell and update minima and maxima final int kthCell = findCellAndUpdateMinMax(inputDataPoint); // 2. Increment positions incrementPositions(1, kthCell + 1, 5); // 2a. Update desired position with increments updateDesiredPositions(); // 3. Adjust heights of m[2-4] if necessary adjustHeightsOfMarkers(); // 4. Return percentile return getPercentileValue(); }
/** * Constructor * * @param initialFive elements required to build Marker * @param p quantile required to be computed */ private Markers(final List<Double> initialFive, final double p) { this(createMarkerArray(initialFive, p)); }
/** * Finds the cell where the input observation / value fits. * * @param observation the input value to be checked for * @return kth cell (of the markers ranging from 1-5) where observed * sample fits */ private int findCellAndUpdateMinMax(final double observation) { k = -1; if (observation < height(1)) { markerArray[1].markerHeight = observation; k = 1; } else if (observation < height(2)) { k = 1; } else if (observation < height(3)) { k = 2; } else if (observation < height(4)) { k = 3; } else if (observation <= height(5)) { k = 4; } else { markerArray[5].markerHeight = observation; k = 4; } return k; }
/** * {@inheritDoc} */ public double estimate(final int index) { if (index < LOW || index > HIGH) { throw new OutOfRangeException(index, LOW, HIGH); } return markerArray[index].estimate(); }
/** * Adjust marker heights by setting quantile estimates to middle markers. */ private void adjustHeightsOfMarkers() { for (int i = LOW; i <= HIGH; i++) { estimate(i); } }
/** * Returns the percentile computed thus far. * * @return height of mid point marker */ public double getPercentileValue() { return height(3); }
/** * A creation method to build Markers * * @param initialFive list of initial five elements * @param p the quantile desired * @return an instance of PSquareMarkers */ public static PSquareMarkers newMarkers(final List<Double> initialFive, final double p) { return new Markers(initialFive, p); }
/** * Finds the cell where the input observation / value fits. * * @param observation the input value to be checked for * @return kth cell (of the markers ranging from 1-5) where observed * sample fits */ private int findCellAndUpdateMinMax(final double observation) { k = -1; if (observation < height(1)) { markerArray[1].markerHeight = observation; k = 1; } else if (observation < height(2)) { k = 1; } else if (observation < height(3)) { k = 2; } else if (observation < height(4)) { k = 3; } else if (observation <= height(5)) { k = 4; } else { markerArray[5].markerHeight = observation; k = 4; } return k; }
/** * Process a data point * * @param inputDataPoint is the data point passed * @return computed percentile */ public double processDataPoint(final double inputDataPoint) { // 1. Find cell and update minima and maxima final int kthCell = findCellAndUpdateMinMax(inputDataPoint); // 2. Increment positions incrementPositions(1, kthCell + 1, 5); // 2a. Update desired position with increments updateDesiredPositions(); // 3. Adjust heights of m[2-4] if necessary adjustHeightsOfMarkers(); // 4. Return percentile return getPercentileValue(); }
/** * {@inheritDoc}.Clone Markers * * @return cloned object */ @Override public Object clone() { return new Markers(new Marker[] { new Marker(), (Marker) markerArray[1].clone(), (Marker) markerArray[2].clone(), (Marker) markerArray[3].clone(), (Marker) markerArray[4].clone(), (Marker) markerArray[5].clone() }); }
/** * Constructor * * @param initialFive elements required to build Marker * @param p quantile required to be computed */ private Markers(final List<Double> initialFive, final double p) { this(createMarkerArray(initialFive, p)); }
/** * A creation method to build Markers * * @param initialFive list of initial five elements * @param p the quantile desired * @return an instance of PSquareMarkers */ public static PSquareMarkers newMarkers(final List<Double> initialFive, final double p) { return new Markers(initialFive, p); }
/** * Adjust marker heights by setting quantile estimates to middle markers. */ private void adjustHeightsOfMarkers() { for (int i = LOW; i <= HIGH; i++) { estimate(i); } }
/** * Returns the percentile computed thus far. * * @return height of mid point marker */ public double getPercentileValue() { return height(3); }
/** * {@inheritDoc} */ public double estimate(final int index) { if (index < LOW || index > HIGH) { throw new OutOfRangeException(index, LOW, HIGH); } return markerArray[index].estimate(); }