@@ -51,6 +51,8 @@ public function testEmpty(): void
51
51
52
52
$ this ->assertSame (0 , $ variance ->getCount ());
53
53
$ this ->assertNan ($ variance ->getMean ());
54
+ $ this ->assertNan ($ variance ->getMin ());
55
+ $ this ->assertNan ($ variance ->getMax ());
54
56
$ this ->assertNan ($ variance ->getVariance ());
55
57
$ this ->assertNan ($ variance ->getStandardDeviation ());
56
58
}
@@ -72,10 +74,26 @@ public function testOne(): void
72
74
73
75
$ this ->assertSame (1 , $ variance ->getCount ());
74
76
$ this ->assertSame (M_PI , $ variance ->getMean ());
77
+ $ this ->assertSame (M_PI , $ variance ->getMin ());
78
+ $ this ->assertSame (M_PI , $ variance ->getMax ());
75
79
$ this ->assertSame (0.0 , $ variance ->getVariance ());
76
80
$ this ->assertSame (0.0 , $ variance ->getStandardDeviation ());
77
81
}
78
82
83
+ public function testOneNegative (): void
84
+ {
85
+ $ variance = new RunningVariance ();
86
+ $ variance ->observe (-1.01 );
87
+
88
+ $ this ->assertSame (1 , $ variance ->getCount ());
89
+ $ this ->assertSame (-1.01 , $ variance ->getMean ());
90
+ $ this ->assertSame (-1.01 , $ variance ->getMin ());
91
+ $ this ->assertSame (-1.01 , $ variance ->getMax ());
92
+ $ this ->assertSame (0.0 , $ variance ->getVariance ());
93
+ $ this ->assertSame (0.0 , $ variance ->getStandardDeviation ());
94
+ }
95
+
96
+
79
97
public function testTwo (): void
80
98
{
81
99
$ variance = new RunningVariance ();
@@ -84,6 +102,8 @@ public function testTwo(): void
84
102
85
103
$ this ->assertSame (2 , $ variance ->getCount ());
86
104
$ this ->assertSame (M_PI , $ variance ->getMean ());
105
+ $ this ->assertSame (M_PI , $ variance ->getMin ());
106
+ $ this ->assertSame (M_PI , $ variance ->getMax ());
87
107
$ this ->assertSame (0.0 , $ variance ->getVariance ());
88
108
$ this ->assertSame (0.0 , $ variance ->getStandardDeviation ());
89
109
}
@@ -96,6 +116,8 @@ public function testNAN(): void
96
116
97
117
$ this ->assertSame (2 , $ variance ->getCount ());
98
118
$ this ->assertNan ($ variance ->getMean ());
119
+ $ this ->assertSame (M_PI , $ variance ->getMin ());
120
+ $ this ->assertSame (M_PI , $ variance ->getMax ());
99
121
$ this ->assertNan ($ variance ->getVariance ());
100
122
$ this ->assertNan ($ variance ->getStandardDeviation ());
101
123
}
@@ -111,6 +133,8 @@ public function testFive(): void
111
133
112
134
$ this ->assertSame (5 , $ variance ->getCount ());
113
135
$ this ->assertSame (5.0 , $ variance ->getMean ());
136
+ $ this ->assertSame (2.0 , $ variance ->getMin ());
137
+ $ this ->assertSame (8.0 , $ variance ->getMax ());
114
138
$ this ->assertEqualsWithDelta (5.0 , $ variance ->getVariance (), 0.0001 );
115
139
$ this ->assertEqualsWithDelta (sqrt (5.0 ), $ variance ->getStandardDeviation (), 0.0001 );
116
140
}
@@ -128,6 +152,8 @@ public function testCopy(): void
128
152
129
153
$ this ->assertSame (5 , $ variance ->getCount ());
130
154
$ this ->assertSame (5.0 , $ variance ->getMean ());
155
+ $ this ->assertSame (2.0 , $ variance ->getMin ());
156
+ $ this ->assertSame (8.0 , $ variance ->getMax ());
131
157
$ this ->assertEqualsWithDelta (5.0 , $ variance ->getVariance (), 0.0001 );
132
158
$ this ->assertEqualsWithDelta (sqrt (5.0 ), $ variance ->getStandardDeviation (), 0.0001 );
133
159
}
@@ -145,6 +171,8 @@ public function testFiveMerged(): void
145
171
146
172
$ this ->assertSame (5 , $ variance ->getCount ());
147
173
$ this ->assertSame (5.0 , $ variance ->getMean ());
174
+ $ this ->assertSame (2.0 , $ variance ->getMin ());
175
+ $ this ->assertSame (8.0 , $ variance ->getMax ());
148
176
$ this ->assertEqualsWithDelta (5.0 , $ variance ->getVariance (), 0.0001 );
149
177
$ this ->assertEqualsWithDelta (sqrt (5.0 ), $ variance ->getStandardDeviation (), 0.0001 );
150
178
}
@@ -164,6 +192,8 @@ public function testFiveMergedTwice(): void
164
192
165
193
$ this ->assertSame (5 , $ variance ->getCount ());
166
194
$ this ->assertSame (5.0 , $ variance ->getMean ());
195
+ $ this ->assertSame (2.0 , $ variance ->getMin ());
196
+ $ this ->assertSame (8.0 , $ variance ->getMax ());
167
197
$ this ->assertEqualsWithDelta (5.0 , $ variance ->getVariance (), 0.0001 );
168
198
$ this ->assertEqualsWithDelta (sqrt (5.0 ), $ variance ->getStandardDeviation (), 0.0001 );
169
199
}
@@ -185,6 +215,8 @@ public function testFiveMergedThrice(): void
185
215
186
216
$ this ->assertSame (5 , $ variance ->getCount ());
187
217
$ this ->assertSame (5.0 , $ variance ->getMean ());
218
+ $ this ->assertSame (2.0 , $ variance ->getMin ());
219
+ $ this ->assertSame (8.0 , $ variance ->getMax ());
188
220
$ this ->assertEqualsWithDelta (5.0 , $ variance ->getVariance (), 0.0001 );
189
221
$ this ->assertEqualsWithDelta (sqrt (5.0 ), $ variance ->getStandardDeviation (), 0.0001 );
190
222
}
0 commit comments