/** * {@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 */ public String toString() { StringBuffer outBuffer = new StringBuffer(); outBuffer.append("MultivariateSummaryStatistics:\n"); outBuffer.append("n: " + getN() + "\n"); append(outBuffer, getMin(), "min: ", ", ", "\n"); append(outBuffer, getMax(), "max: ", ", ", "\n"); append(outBuffer, getMean(), "mean: ", ", ", "\n"); append(outBuffer, getGeometricMean(), "geometric mean: ", ", ", "\n"); append(outBuffer, getSumSq(), "sum of squares: ", ", ", "\n"); append(outBuffer, getSumLog(), "sum of logarithms: ", ", ", "\n"); append(outBuffer, getStandardDeviation(), "standard deviation: ", ", ", "\n"); outBuffer.append("covariance: " + getCovariance().toString() + "\n"); 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 IllegalStateException if data has already been added * (i.e if n > 0) */ private void setImpl(StorelessUnivariateStatistic[] newImpl, StorelessUnivariateStatistic[] oldImpl) throws DimensionMismatchException, IllegalStateException { checkEmpty(); checkDimension(newImpl.length); System.arraycopy(newImpl, 0, oldImpl, 0, newImpl.length); }
@Override public String toString() { return "\nPixelProfileModel[\n" + "\tcount = " + statistics.getN() + "\n" + "\tmean = " + Arrays.toString(statistics.getMean()) + "\n" + "\tcovar = " + statistics.getCovariance() + "\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 MathUtils.equalsIncludingNaN(stat.getGeometricMean(), getGeometricMean()) && MathUtils.equalsIncludingNaN(stat.getMax(), getMax()) && MathUtils.equalsIncludingNaN(stat.getMean(), getMean()) && MathUtils.equalsIncludingNaN(stat.getMin(), getMin()) && MathUtils.equalsIncludingNaN(stat.getN(), getN()) && MathUtils.equalsIncludingNaN(stat.getSum(), getSum()) && MathUtils.equalsIncludingNaN(stat.getSumSq(), getSumSq()) && MathUtils.equalsIncludingNaN(stat.getSumLog(), getSumLog()) && stat.getCovariance().equals( getCovariance()); }
/** * @return the inverse of the covariance matrix */ public Matrix getInverseCovariance() { if (mean == null) { mean = statistics.getMean(); invCovar = new Matrix(statistics.getCovariance().getData()).inverse(); } return invCovar; }
/** * {@inheritDoc} */ @Override public synchronized long getN() { return super.getN(); }
/** * {@inheritDoc} */ @Override public synchronized double[] getMean() { return super.getMean(); }
/** * {@inheritDoc} */ @Override public synchronized RealMatrix getCovariance() { return super.getCovariance(); }
/** * {@inheritDoc} */ @Override public synchronized void clear() { super.clear(); }
/** * {@inheritDoc} */ @Override public synchronized boolean equals(Object object) { return super.equals(object); }
/** * {@inheritDoc} */ @Override public synchronized int getDimension() { return super.getDimension(); }
/** * 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>SummaryStatistics</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 MathUtils.equals(stat.getGeometricMean(), getGeometricMean()) && MathUtils.equals(stat.getMax(), getMax()) && MathUtils.equals(stat.getMean(), getMean()) && MathUtils.equals(stat.getMin(), getMin()) && MathUtils.equals(stat.getN(), getN()) && MathUtils.equals(stat.getSum(), getSum()) && MathUtils.equals(stat.getSumSq(), getSumSq()) && MathUtils.equals(stat.getSumLog(), getSumLog()) && stat.getCovariance().equals( getCovariance()); }
/** * @return the inverse of the covariance matrix */ public Matrix getInverseCovariance() { if (mean == null) { mean = statistics.getMean(); invCovar = new Matrix(statistics.getCovariance().getData()).inverse(); } return invCovar; }
@Override public String toString() { return "\nPixelProfileModel[\n" + "\tcount = " + statistics.getN() + "\n" + "\tmean = " + Arrays.toString(statistics.getMean()) + "\n" + "\tcovar = " + statistics.getCovariance() + "\n" + "]"; }
/** * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getN() */ public synchronized long getN() { return super.getN(); }
/** * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getMean() */ public synchronized double[] getMean() { return super.getMean(); }
/** * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#getCovariance() */ public synchronized RealMatrix getCovariance() { return super.getCovariance(); }
/** * @see org.apache.commons.math.stat.descriptive.MultivariateSummaryStatistics#clear() */ public synchronized void clear() { super.clear(); }