/*
 * Copyright 2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.math.stat.univariate;

import java.io.Serializable;

/**
 *  Value object representing the results of a univariate statistical summary.
 *
 * @version $Revision: 1.3 $ $Date: 2004/06/23 16:26:16 $
 */
public class StatisticalSummaryValues implements Serializable, 
    StatisticalSummary {
   
    /** Serialization id */
    static final long serialVersionUID = -5108854841843722536L;

    /** The sample mean */
    private double mean = Double.NaN;
    
    /** The sample variance */
    private double variance = Double.NaN;
    
    /** The number of observations in the sample */
    private long n = 0;
    
    /** The maximum value */
    private double max = Double.NaN;
    
    /** The minimum value */
    private double min = Double.NaN;
    
    /** The sum of the sample values */
    private double sum = Double.NaN;
    
    /**
      * Constructor
      * 
      * @param mean  the sample mean
      * @param variance  the sample variance
      * @param n  the number of observations in the sample 
      * @param max  the maximum value
      * @param min  the minimum value
      * @param sum  the sum of the values
     */
    public StatisticalSummaryValues(double mean, double variance, long n,
        double max, double min, double sum) {
        super();
        this.mean = mean;
        this.variance = variance;
        this.n = n;
        this.max = max;
        this.min = min;
        this.sum = sum;
    }
    
    /** Private no argument contstructor */
    private StatisticalSummaryValues() {
        super();
    }

    
    /**
     * @return Returns the max.
     */
    public double getMax() {
        return max;
    }

    /**
     * @return Returns the mean.
     */
    public double getMean() {
        return mean;
    }

    /**
     * @return Returns the min.
     */
    public double getMin() {
        return min;
    }

    /**
     * @return Returns the number of values.
     */
    public long getN() {
        return n;
    }

    /**
     * @return Returns the sum.
     */
    public double getSum() {
        return sum;
    }
    
    /**
     * @return Returns the standard deviation
     */
    public double getStandardDeviation() {
        return Math.sqrt(variance);
    }

    /**
     * @return Returns the variance.
     */
    public double getVariance() {
        return variance;
    }

}

@@ -687,16 +687,63 @@
 lizable;
+%0Aimport org.apache.commons.math.util.MathUtils;
 %0A%0A/**%0A *
@@ -847,17 +847,17 @@
 sion: 1.
-3
+4
  $ $Date
@@ -871,18 +871,18 @@
 06/2
-3 16:26:16
+9 02:18:22
  $%0A 
@@ -2237,21 +2237,16 @@
 %0A    %7D%0A%0A
-    %0A
     /**%0A
@@ -3002,24 +3002,24 @@
 ariance() %7B%0A
-
         retu
@@ -3036,12 +3036,1503 @@
 e;%0A    %7D
+%0A    %0A    /**%0A     * Returns true iff %3Ccode%3Eobject%3C/code%3E is a %0A     * %3Ccode%3EStatisticalSummaryValues%3C/code%3E instance and all statistics have%0A     *  the same values as this.%0A     * %0A     * @param object the object to test equality against.%0A     * @return true if object equals this%0A     */%0A    public boolean equals(Object object) %7B%0A        if (object == this ) %7B%0A            return true;%0A        %7D%0A        if (object instanceof StatisticalSummaryValues == false) %7B%0A            return false;%0A        %7D%0A        StatisticalSummaryValues stat = (StatisticalSummaryValues) object;%0A        return (MathUtils.equals(stat.getMax(), this.getMax()) && %0A                MathUtils.equals(stat.getMean(),this.getMean()) &&%0A                MathUtils.equals(stat.getMin(),this.getMin()) &&%0A                MathUtils.equals(stat.getN(), this.getN()) &&%0A                MathUtils.equals(stat.getSum(), this.getSum()) &&%0A                MathUtils.equals(stat.getVariance(),this.getVariance()));%0A    %7D%0A    %0A    /**%0A     * Returns hash code based on values of statistics%0A     * %0A     * @return hash code%0A     */%0A    public int hashCode() %7B%0A        int result = 31 + MathUtils.hash(getMax());%0A        result = result * 31 + MathUtils.hash(getMean());%0A        result = result * 31 + MathUtils.hash(getMin());%0A        result = result * 31 + MathUtils.hash(getN());%0A        result = result * 31 + MathUtils.hash(getSum());%0A        result = result * 31 + MathUtils.hash(getVariance());%0A        return result;%0A    %7D
 %0A%0A%7D%0A

Implemented equals and hashcode.