/** * Tests whether the specified statistic is currently set. Note that * statistics can be set indirectly because of logical groupings. For * example, if {@code Statistic.MEAN} is set then {@code SDEV} and * {@code VARIANCE} will also be set as these three are calculated * together. The same is true for {@code MIN}, {@code MAX} and {@code RANGE}. * * @param stat the statistic * * @return {@code true} if the statistic has been set; {@code false} otherwise. */ public boolean isSet(Statistic stat) { return findProcessor(stat) != null; }
/** * Gets the current value of a running statistic. If there have not * been enough samples provided to compute the statistic, Double.NaN * is returned. * * @param stat the statistic * @return the current value of the statistic * * @throws IllegalStateException if {@code stat} was not previously set */ public Double getStatisticValue(Statistic stat) { Processor p = findProcessor(stat); if (p == null) { throw new IllegalStateException( "requesting a result for a statistic that hasn't been set: " + stat); } return p.get(stat); }
/** * Gets the number of NoData values (including NaN) that have been offered. * Note that different statistics might have been set at different * times in the sampling process. * * @param stat the statistic * * @return number of NoData samples offered * * @throws IllegalArgumentException if the statistic hasn't been set */ public long getNumNoData(Statistic stat) { Processor p = findProcessor(stat); if (p == null) { throw new IllegalArgumentException( "requesting sample size for a statistic that is not set: " + stat); } return p.getNumNoData(); }
/** * Gets the number of NaN values that have been offered. * Note that different statistics might have been set at different * times in the sampling process. * * @param stat the statistic * * @return number of NaN samples offered * * @throws IllegalArgumentException if the statistic hasn't been set */ public long getNumNaN(Statistic stat) { Processor p = findProcessor(stat); if (p == null) { throw new IllegalArgumentException( "requesting sample size for a statistic that is not set: " + stat); } return p.getNumNaN(); }
/** * Gets the number of sample values that have been accepted for the * specified {@code Statistic}. * <p> * Note that different statistics might have been set at different * times in the sampling process. * * @param stat the statistic * * @return number of samples that have been accepted * * @throws IllegalArgumentException if the statistic hasn't been set */ public long getNumAccepted(Statistic stat) { Processor p = findProcessor(stat); if (p == null) { throw new IllegalArgumentException( "requesting sample size for a statistic that is not set: " + stat); } return p.getNumAccepted(); }
/** * Gets the number of sample values that have been <b>offered</b> for the * specified {@code Statistic}. This might be higher than the value * returned by {@link #getNumAccepted} due to {@code nulls}, * {@code Double.NaNs} and excluded values in the data stream. * <p> * Note that different statistics might have been set at different * times in the sampling process. * * @param stat the statistic * * @return number of samples that have been accepted * * @throws IllegalArgumentException if the statistic hasn't been set */ public long getNumOffered(Statistic stat) { Processor p = findProcessor(stat); if (p == null) { throw new IllegalArgumentException( "requesting sample size for a statistic that is not set: " + stat); } return p.getNumOffered(); }
/** * Adds a statistic to those calculated by this sampler. * If the same statistic was previously set then calling this method * has no effect. * * @param stat the statistic * @see Statistic */ public void setStatistic(Statistic stat) { Processor p = findProcessor(stat); if (p == null) { p = factory.getForStatistic(stat); if (p == null) { LOGGER.log(Level.SEVERE, "Unsupported Statistic: {0}", stat); } else { processors.add(p); // apply cached excluded ranges to the new processor for (Range<Double> range : ranges) { p.addRange(range, rangesType); } for (Range<Double> nRange : noDataRanges) { p.addNoDataRange(nRange); } } } }