/** * {@inheritDoc} */ @Override public synchronized void addValue(double[] value) throws DimensionMismatchException { super.addValue(value); }
/** * Generates a text report displaying * summary statistics from values that * have been added. * @return String with line feeds displaying statistics */ @Override public String toString() { final String separator = ", "; final String suffix = System.getProperty("line.separator"); StringBuilder outBuffer = new StringBuilder(); outBuffer.append("MultivariateSummaryStatistics:" + suffix); outBuffer.append("n: " + getN() + suffix); append(outBuffer, getMin(), "min: ", separator, suffix); append(outBuffer, getMax(), "max: ", separator, suffix); append(outBuffer, getMean(), "mean: ", separator, suffix); append(outBuffer, getGeometricMean(), "geometric mean: ", separator, suffix); append(outBuffer, getSumSq(), "sum of squares: ", separator, suffix); append(outBuffer, getSumLog(), "sum of logarithms: ", separator, suffix); append(outBuffer, getStandardDeviation(), "standard deviation: ", separator, suffix); outBuffer.append("covariance: " + getCovariance().toString() + suffix); return outBuffer.toString(); }
/** * Sets statistics implementations. * @param newImpl new implementations for statistics * @param oldImpl old implementations for statistics * @throws DimensionMismatchException if the array dimension * does not match the one used at construction * @throws MathIllegalStateException if data has already been added * (i.e. if n > 0) */ private void setImpl(StorelessUnivariateStatistic[] newImpl, StorelessUnivariateStatistic[] oldImpl) throws MathIllegalStateException, DimensionMismatchException { checkEmpty(); checkDimension(newImpl.length); System.arraycopy(newImpl, 0, oldImpl, 0, newImpl.length); }
/** * Returns true iff <code>object</code> is a <code>MultivariateSummaryStatistics</code> * instance and all statistics have the same values as this. * @param object the object to test equality against. * @return true if object equals this */ @Override public boolean equals(Object object) { if (object == this ) { return true; } if (object instanceof MultivariateSummaryStatistics == false) { return false; } MultivariateSummaryStatistics stat = (MultivariateSummaryStatistics) object; return MathArrays.equalsIncludingNaN(stat.getGeometricMean(), getGeometricMean()) && MathArrays.equalsIncludingNaN(stat.getMax(), getMax()) && MathArrays.equalsIncludingNaN(stat.getMean(), getMean()) && MathArrays.equalsIncludingNaN(stat.getMin(), getMin()) && Precision.equalsIncludingNaN(stat.getN(), getN()) && MathArrays.equalsIncludingNaN(stat.getSum(), getSum()) && MathArrays.equalsIncludingNaN(stat.getSumSq(), getSumSq()) && MathArrays.equalsIncludingNaN(stat.getSumLog(), getSumLog()) && stat.getCovariance().equals( getCovariance()); }
/** * {@inheritDoc} */ @Override public synchronized void clear() { super.clear(); }
/** * {@inheritDoc} */ @Override public synchronized StorelessUnivariateStatistic[] getGeoMeanImpl() { return super.getGeoMeanImpl(); }
/** * {@inheritDoc} */ @Override public synchronized double[] getGeometricMean() { return super.getGeometricMean(); }
/** * {@inheritDoc} */ @Override public synchronized int getDimension() { return super.getDimension(); }
/** * {@inheritDoc} */ @Override public synchronized RealMatrix getCovariance() { return super.getCovariance(); }
/** * {@inheritDoc} */ @Override public synchronized boolean equals(Object object) { return super.equals(object); }
/** * Add an n-tuple to the data * * @param value the n-tuple to add * @throws DimensionMismatchException if the length of the array * does not match the one used at construction */ public void addValue(double[] value) throws DimensionMismatchException { checkDimension(value.length); for (int i = 0; i < k; ++i) { double v = value[i]; sumImpl[i].increment(v); sumSqImpl[i].increment(v); minImpl[i].increment(v); maxImpl[i].increment(v); sumLogImpl[i].increment(v); geoMeanImpl[i].increment(v); meanImpl[i].increment(v); } covarianceImpl.increment(value); n++; }
/** * Returns hash code based on values of statistics * * @return hash code */ @Override public int hashCode() { int result = 31 + MathUtils.hash(getGeometricMean()); result = result * 31 + MathUtils.hash(getGeometricMean()); result = result * 31 + MathUtils.hash(getMax()); result = result * 31 + MathUtils.hash(getMean()); result = result * 31 + MathUtils.hash(getMin()); result = result * 31 + MathUtils.hash(getN()); result = result * 31 + MathUtils.hash(getSum()); result = result * 31 + MathUtils.hash(getSumSq()); result = result * 31 + MathUtils.hash(getSumLog()); result = result * 31 + getCovariance().hashCode(); return result; }
/** * {@inheritDoc} */ @Override public synchronized void clear() { super.clear(); }
/** * {@inheritDoc} */ @Override public synchronized StorelessUnivariateStatistic[] getGeoMeanImpl() { return super.getGeoMeanImpl(); }
/** * {@inheritDoc} */ @Override public synchronized double[] getGeometricMean() { return super.getGeometricMean(); }
/** * {@inheritDoc} */ @Override public synchronized int getDimension() { return super.getDimension(); }
/** * {@inheritDoc} */ @Override public synchronized RealMatrix getCovariance() { return super.getCovariance(); }
/** * {@inheritDoc} */ @Override public synchronized boolean equals(Object object) { return super.equals(object); }
/** * Add an n-tuple to the data * * @param value the n-tuple to add * @throws DimensionMismatchException if the length of the array * does not match the one used at construction */ public void addValue(double[] value) throws DimensionMismatchException { checkDimension(value.length); for (int i = 0; i < k; ++i) { double v = value[i]; sumImpl[i].increment(v); sumSqImpl[i].increment(v); minImpl[i].increment(v); maxImpl[i].increment(v); sumLogImpl[i].increment(v); geoMeanImpl[i].increment(v); meanImpl[i].increment(v); } covarianceImpl.increment(value); n++; }
/** * Returns true iff <code>object</code> is a <code>MultivariateSummaryStatistics</code> * instance and all statistics have the same values as this. * @param object the object to test equality against. * @return true if object equals this */ @Override public boolean equals(Object object) { if (object == this ) { return true; } if (object instanceof MultivariateSummaryStatistics == false) { return false; } MultivariateSummaryStatistics stat = (MultivariateSummaryStatistics) object; return MathArrays.equalsIncludingNaN(stat.getGeometricMean(), getGeometricMean()) && MathArrays.equalsIncludingNaN(stat.getMax(), getMax()) && MathArrays.equalsIncludingNaN(stat.getMean(), getMean()) && MathArrays.equalsIncludingNaN(stat.getMin(), getMin()) && Precision.equalsIncludingNaN(stat.getN(), getN()) && MathArrays.equalsIncludingNaN(stat.getSum(), getSum()) && MathArrays.equalsIncludingNaN(stat.getSumSq(), getSumSq()) && MathArrays.equalsIncludingNaN(stat.getSumLog(), getSumLog()) && stat.getCovariance().equals( getCovariance()); }