/** * WindowSize controls the number of values that contribute to the * reported statistics. For example, if windowSize is set to 3 and the * values {1,2,3,4,5} have been added <strong> in that order</strong> then * the <i>available values</i> are {3,4,5} and all reported statistics will * be based on these values. If {@code windowSize} is decreased as a result * of this call and there are more than the new value of elements in the * current dataset, values from the front of the array are discarded to * reduce the dataset to {@code windowSize} elements. * * @param windowSize sets the size of the window. * @throws MathIllegalArgumentException if window size is less than 1 but * not equal to {@link #INFINITE_WINDOW} */ public void setWindowSize(int windowSize) throws MathIllegalArgumentException { if (windowSize < 1 && windowSize != INFINITE_WINDOW) { throw new MathIllegalArgumentException( LocalizedFormats.NOT_POSITIVE_WINDOW_SIZE, windowSize); } this.windowSize = windowSize; // We need to check to see if we need to discard elements // from the front of the array. If the windowSize is less than // the current number of elements. if (windowSize != INFINITE_WINDOW && windowSize < eDA.getNumElements()) { eDA.discardFrontElements(eDA.getNumElements() - windowSize); } }
/** * WindowSize controls the number of values that contribute to the * reported statistics. For example, if windowSize is set to 3 and the * values {1,2,3,4,5} have been added <strong> in that order</strong> then * the <i>available values</i> are {3,4,5} and all reported statistics will * be based on these values. If {@code windowSize} is decreased as a result * of this call and there are more than the new value of elements in the * current dataset, values from the front of the array are discarded to * reduce the dataset to {@code windowSize} elements. * * @param windowSize sets the size of the window. * @throws MathIllegalArgumentException if window size is less than 1 but * not equal to {@link #INFINITE_WINDOW} */ public void setWindowSize(int windowSize) throws MathIllegalArgumentException { if (windowSize < 1 && windowSize != INFINITE_WINDOW) { throw new MathIllegalArgumentException( LocalizedFormats.NOT_POSITIVE_WINDOW_SIZE, windowSize); } this.windowSize = windowSize; // We need to check to see if we need to discard elements // from the front of the array. If the windowSize is less than // the current number of elements. if (windowSize != INFINITE_WINDOW && windowSize < eDA.getNumElements()) { eDA.discardFrontElements(eDA.getNumElements() - windowSize); } }