/** * {@inheritDoc} */ @Override public GeometricMean copy() { GeometricMean result = new GeometricMean(); copy(this, result); return result; }
/** * <p>Sets the implementation for the sum of logs.</p> * <p>This method must be activated before any data has been added - i.e., * before {@link #increment(double) increment} has been used to add data; * otherwise an IllegalStateException will be thrown.</p> * * @param sumLogImpl the StorelessUnivariateStatistic instance to use * for computing the log sum * @throws IllegalStateException if data has already been added * (i.e if n > 0) */ public void setSumLogImpl( StorelessUnivariateStatistic sumLogImpl) { checkEmpty(); this.sumOfLogs = sumLogImpl; }
/** * Returns the geometric mean of the entries in the input array, or * <code>Double.NaN</code> if the array is empty. * <p> * Throws <code>IllegalArgumentException</code> if the array is null.</p> * <p> * See {@link org.apache.commons.math.stat.descriptive.moment.GeometricMean} * for details on the computing algorithm.</p> * * @param values the input array * @return the geometric mean of the values or Double.NaN if the array is empty * @throws IllegalArgumentException if the array is null */ public static double geometricMean(final double[] values) { return GEOMETRIC_MEAN.evaluate(values); }
/** * Copies source to dest. * <p>Neither source nor dest can be null.</p> * * @param source GeometricMean to copy * @param dest GeometricMean to copy to * @throws NullPointerException if either source or dest is null */ public static void copy(GeometricMean source, GeometricMean dest) { dest.setData(source.getDataRef()); dest.sumOfLogs = source.sumOfLogs.copy(); }
/** * Throws IllegalStateException if n > 0. */ private void checkEmpty() { if (getN() > 0) { throw new IllegalStateException( "Implementation must be configured before values are added."); } }
/** * <p>Sets the implementation for the sum of logs.</p> * <p>This method must be activated before any data has been added - i.e., * before {@link #addValue(double) addValue} has been used to add data; * otherwise an IllegalStateException will be thrown.</p> * * @param sumLogImpl the StorelessUnivariateStatistic instance to use * for computing the log sum * @throws IllegalStateException if data has already been added * (i.e if n > 0) * @since 1.2 */ public void setSumLogImpl( StorelessUnivariateStatistic sumLogImpl) { checkEmpty(); this.sumLogImpl = sumLogImpl; geoMean.setSumLogImpl(sumLogImpl); }
/** * Construct a MultivariateSummaryStatistics instance * @param k dimension of the data * @param isCovarianceBiasCorrected if true, the unbiased sample * covariance is computed, otherwise the biased population covariance * is computed */ public MultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) { this.k = k; sumImpl = new StorelessUnivariateStatistic[k]; sumSqImpl = new StorelessUnivariateStatistic[k]; minImpl = new StorelessUnivariateStatistic[k]; maxImpl = new StorelessUnivariateStatistic[k]; sumLogImpl = new StorelessUnivariateStatistic[k]; geoMeanImpl = new StorelessUnivariateStatistic[k]; meanImpl = new StorelessUnivariateStatistic[k]; for (int i = 0; i < k; ++i) { sumImpl[i] = new Sum(); sumSqImpl[i] = new SumOfSquares(); minImpl[i] = new Min(); maxImpl[i] = new Max(); sumLogImpl[i] = new SumOfLogs(); geoMeanImpl[i] = new GeometricMean(); meanImpl[i] = new Mean(); } covarianceImpl = new VectorialCovariance(k, isCovarianceBiasCorrected); }
/** * Copy constructor, creates a new {@code GeometricMean} identical * to the {@code original} * * @param original the {@code GeometricMean} instance to copy */ public GeometricMean(GeometricMean original) { super(); copy(original, this); }
/** * <p> * Sets the implementation for the sum of logs. * </p> * <p> * This method must be activated before any data has been added - i.e., * before {@link #addValue(double) addValue} has been used to add data; * otherwise an IllegalStateException will be thrown. * </p> * @param sumLogImpl the StorelessUnivariateStatistic instance to use for * computing the log sum * @throws IllegalStateException if data has already been added (i.e if n > * 0) * @since 1.2 */ public void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl) { checkEmpty(); this.sumLogImpl = sumLogImpl; geoMean.setSumLogImpl(sumLogImpl); }
/** * Construct a MultivariateSummaryStatistics instance * @param k dimension of the data * @param isCovarianceBiasCorrected if true, the unbiased sample * covariance is computed, otherwise the biased population covariance * is computed */ public MultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) { this.k = k; sumImpl = new StorelessUnivariateStatistic[k]; sumSqImpl = new StorelessUnivariateStatistic[k]; minImpl = new StorelessUnivariateStatistic[k]; maxImpl = new StorelessUnivariateStatistic[k]; sumLogImpl = new StorelessUnivariateStatistic[k]; geoMeanImpl = new StorelessUnivariateStatistic[k]; meanImpl = new StorelessUnivariateStatistic[k]; for (int i = 0; i < k; ++i) { sumImpl[i] = new Sum(); sumSqImpl[i] = new SumOfSquares(); minImpl[i] = new Min(); maxImpl[i] = new Max(); sumLogImpl[i] = new SumOfLogs(); geoMeanImpl[i] = new GeometricMean(); meanImpl[i] = new Mean(); } covarianceImpl = new VectorialCovariance(k, isCovarianceBiasCorrected); }
/** * Copy constructor, creates a new {@code GeometricMean} identical * to the {@code original} * * @param original the {@code GeometricMean} instance to copy */ public GeometricMean(GeometricMean original) { super(); copy(original, this); }
/** * {@inheritDoc} */ @Override public GeometricMean copy() { GeometricMean result = new GeometricMean(); copy(this, result); return result; }
/** * Returns the geometric mean of the entries in the input array, or * <code>Double.NaN</code> if the array is empty. * <p> * Throws <code>IllegalArgumentException</code> if the array is null.</p> * <p> * See {@link org.apache.commons.math.stat.descriptive.moment.GeometricMean} * for details on the computing algorithm.</p> * * @param values the input array * @return the geometric mean of the values or Double.NaN if the array is empty * @throws IllegalArgumentException if the array is null */ public static double geometricMean(final double[] values) { return geometricMean.evaluate(values); }
/** * <p>Sets the implementation for the sum of logs.</p> * <p>This method must be activated before any data has been added - i.e., * before {@link #increment(double) increment} has been used to add data; * otherwise an IllegalStateException will be thrown.</p> * * @param sumLogImpl the StorelessUnivariateStatistic instance to use * for computing the log sum * @throws IllegalStateException if data has already been added * (i.e if n > 0) */ public void setSumLogImpl( StorelessUnivariateStatistic sumLogImpl) { checkEmpty(); this.sumOfLogs = sumLogImpl; }
/** * <p> * Sets the implementation for the sum of logs. * </p> * <p> * This method must be activated before any data has been added - i.e., * before {@link #addValue(double) addValue} has been used to add data; * otherwise an IllegalStateException will be thrown. * </p> * @param sumLogImpl the StorelessUnivariateStatistic instance to use for * computing the log sum * @throws IllegalStateException if data has already been added (i.e if n > * 0) * @since 1.2 */ public void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl) { checkEmpty(); this.sumLogImpl = sumLogImpl; geoMean.setSumLogImpl(sumLogImpl); }
/** * Construct a MultivariateSummaryStatistics instance * @param k dimension of the data * @param isCovarianceBiasCorrected if true, the unbiased sample * covariance is computed, otherwise the biased population covariance * is computed */ public MultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) { this.k = k; sumImpl = new StorelessUnivariateStatistic[k]; sumSqImpl = new StorelessUnivariateStatistic[k]; minImpl = new StorelessUnivariateStatistic[k]; maxImpl = new StorelessUnivariateStatistic[k]; sumLogImpl = new StorelessUnivariateStatistic[k]; geoMeanImpl = new StorelessUnivariateStatistic[k]; meanImpl = new StorelessUnivariateStatistic[k]; for (int i = 0; i < k; ++i) { sumImpl[i] = new Sum(); sumSqImpl[i] = new SumOfSquares(); minImpl[i] = new Min(); maxImpl[i] = new Max(); sumLogImpl[i] = new SumOfLogs(); geoMeanImpl[i] = new GeometricMean(); meanImpl[i] = new Mean(); } covarianceImpl = new VectorialCovariance(k, isCovarianceBiasCorrected); }
if (source.getGeoMeanImpl() instanceof GeometricMean) { dest.geoMeanImpl = new GeometricMean((SumOfLogs) dest.sumLogImpl); } else { dest.geoMeanImpl = source.geoMeanImpl.copy(); dest.geoMean = (GeometricMean) dest.geoMeanImpl; } else { GeometricMean.copy(source.geoMean, dest.geoMean);
/** * Returns the geometric mean of the entries in the input array, or * <code>Double.NaN</code> if the array is empty. * <p> * Throws <code>IllegalArgumentException</code> if the array is null.</p> * <p> * See {@link org.apache.commons.math.stat.descriptive.moment.GeometricMean} * for details on the computing algorithm.</p> * * @param values the input array * @return the geometric mean of the values or Double.NaN if the array is empty * @throws IllegalArgumentException if the array is null */ public static double geometricMean(final double[] values) { return GEOMETRIC_MEAN.evaluate(values); }