1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.math.stat.descriptive;
17
18 import java.io.Serializable;
19 import org.apache.commons.math.util.MathUtils;
20
21
22
23
24
25
26 public class StatisticalSummaryValues implements Serializable,
27 StatisticalSummary {
28
29
30 private static final long serialVersionUID = -5108854841843722536L;
31
32
33 private final double mean;
34
35
36 private final double variance;
37
38
39 private final long n;
40
41
42 private final double max;
43
44
45 private final double min;
46
47
48 private final double sum;
49
50
51
52
53
54
55
56
57
58
59
60 public StatisticalSummaryValues(double mean, double variance, long n,
61 double max, double min, double sum) {
62 super();
63 this.mean = mean;
64 this.variance = variance;
65 this.n = n;
66 this.max = max;
67 this.min = min;
68 this.sum = sum;
69 }
70
71
72
73
74 public double getMax() {
75 return max;
76 }
77
78
79
80
81 public double getMean() {
82 return mean;
83 }
84
85
86
87
88 public double getMin() {
89 return min;
90 }
91
92
93
94
95 public long getN() {
96 return n;
97 }
98
99
100
101
102 public double getSum() {
103 return sum;
104 }
105
106
107
108
109 public double getStandardDeviation() {
110 return Math.sqrt(variance);
111 }
112
113
114
115
116 public double getVariance() {
117 return variance;
118 }
119
120
121
122
123
124
125
126
127
128 public boolean equals(Object object) {
129 if (object == this ) {
130 return true;
131 }
132 if (object instanceof StatisticalSummaryValues == false) {
133 return false;
134 }
135 StatisticalSummaryValues stat = (StatisticalSummaryValues) object;
136 return (MathUtils.equals(stat.getMax(), this.getMax()) &&
137 MathUtils.equals(stat.getMean(),this.getMean()) &&
138 MathUtils.equals(stat.getMin(),this.getMin()) &&
139 MathUtils.equals(stat.getN(), this.getN()) &&
140 MathUtils.equals(stat.getSum(), this.getSum()) &&
141 MathUtils.equals(stat.getVariance(),this.getVariance()));
142 }
143
144
145
146
147
148
149 public int hashCode() {
150 int result = 31 + MathUtils.hash(getMax());
151 result = result * 31 + MathUtils.hash(getMean());
152 result = result * 31 + MathUtils.hash(getMin());
153 result = result * 31 + MathUtils.hash(getN());
154 result = result * 31 + MathUtils.hash(getSum());
155 result = result * 31 + MathUtils.hash(getVariance());
156 return result;
157 }
158
159 }