1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.hipparchus.stat.descriptive;
23
24 import java.io.Serializable;
25
26 import org.hipparchus.util.FastMath;
27 import org.hipparchus.util.MathUtils;
28 import org.hipparchus.util.Precision;
29
30
31
32
33
34 public class StatisticalSummaryValues
35 implements Serializable, StatisticalSummary {
36
37
38 private static final long serialVersionUID = 20160406L;
39
40
41 private final double mean;
42
43
44 private final double variance;
45
46
47 private final long n;
48
49
50 private final double max;
51
52
53 private final double min;
54
55
56 private final double sum;
57
58
59
60
61
62
63
64
65
66
67
68 public StatisticalSummaryValues(double mean, double variance, long n,
69 double max, double min, double sum) {
70 super();
71 this.mean = mean;
72 this.variance = variance;
73 this.n = n;
74 this.max = max;
75 this.min = min;
76 this.sum = sum;
77 }
78
79
80
81
82 @Override
83 public double getMax() {
84 return max;
85 }
86
87
88
89
90 @Override
91 public double getMean() {
92 return mean;
93 }
94
95
96
97
98 @Override
99 public double getMin() {
100 return min;
101 }
102
103
104
105
106 @Override
107 public long getN() {
108 return n;
109 }
110
111
112
113
114 @Override
115 public double getSum() {
116 return sum;
117 }
118
119
120
121
122 @Override
123 public double getStandardDeviation() {
124 return FastMath.sqrt(variance);
125 }
126
127
128
129
130 @Override
131 public double getVariance() {
132 return variance;
133 }
134
135
136
137
138
139
140
141
142
143 @Override
144 public boolean equals(Object object) {
145 if (object == this) {
146 return true;
147 }
148 if (!(object instanceof StatisticalSummaryValues)) {
149 return false;
150 }
151 StatisticalSummary other = (StatisticalSummary) object;
152 return Precision.equalsIncludingNaN(other.getMax(), getMax()) &&
153 Precision.equalsIncludingNaN(other.getMean(), getMean()) &&
154 Precision.equalsIncludingNaN(other.getMin(), getMin()) &&
155 Precision.equalsIncludingNaN(other.getN(), getN()) &&
156 Precision.equalsIncludingNaN(other.getSum(), getSum()) &&
157 Precision.equalsIncludingNaN(other.getVariance(), getVariance());
158 }
159
160
161
162
163
164
165 @Override
166 public int hashCode() {
167 int result = 31 + MathUtils.hash(getMax());
168 result = result * 31 + MathUtils.hash(getMean());
169 result = result * 31 + MathUtils.hash(getMin());
170 result = result * 31 + MathUtils.hash(getN());
171 result = result * 31 + MathUtils.hash(getSum());
172 result = result * 31 + MathUtils.hash(getVariance());
173 return result;
174 }
175
176
177
178
179
180
181
182 @Override
183 public String toString() {
184 StringBuilder outBuffer = new StringBuilder(200);
185 String endl = "\n";
186 outBuffer.append("StatisticalSummaryValues:").append(endl).
187 append("n: ").append(getN()).append(endl).
188 append("min: ").append(getMin()).append(endl).
189 append("max: ").append(getMax()).append(endl).
190 append("mean: ").append(getMean()).append(endl).
191 append("std dev: ").append(getStandardDeviation()).append(endl).
192 append("variance: ").append(getVariance()).append(endl).
193 append("sum: ").append(getSum()).append(endl);
194 return outBuffer.toString();
195 }
196
197 }