Skip to content

Commit fe7f9a8

Browse files
committed
Add support for computing a moving maximum
1 parent c730142 commit fe7f9a8

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

lib/node_modules/@stdlib/stats/incr/msummary/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ summary = accumulator( 2.0 ); // [2.0]
5656
'sum': 2.0,
5757
'mean': 2.0,
5858
'variance': 0.0,
59-
'stdev': 0.0
59+
'stdev': 0.0,
60+
'max': 2.0
6061
}
6162
*/
6263

@@ -67,7 +68,8 @@ summary = accumulator( 1.0 ); // [2.0, 1.0]
6768
'sum': 3.0,
6869
'mean': 1.5,
6970
'variance': 0.5,
70-
'stdev': 0.7071067811865476
71+
'stdev': 0.7071067811865476,
72+
'max': 2.0
7173
}
7274
*/
7375

@@ -78,7 +80,8 @@ summary = accumulator( -3.0 ); // [2.0, 1.0, -3.0]
7880
'sum': 0.0,
7981
'mean': 0.0,
8082
'variance': 7.0,
81-
'stdev': 2.6457513110645907
83+
'stdev': 2.6457513110645907,
84+
'max': 2.0
8285
}
8386
*/
8487

lib/node_modules/@stdlib/stats/incr/msummary/docs/repl.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- mean: arithmetic mean.
1818
- variance: unbiased sample variance.
1919
- stdev: corrected sample standard deviation.
20+
- max: maximum value.
2021

2122
The first `W-1` returned summaries will have less statistical support than
2223
subsequent summaries, as `W` values are needed to fill the window buffer.

lib/node_modules/@stdlib/stats/incr/msummary/lib/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var incrmsum = require( '@stdlib/stats/incr/msum' );
2525
var incrmmean = require( '@stdlib/stats/incr/mmean' );
2626
var incrmvariance = require( '@stdlib/stats/incr/mvariance' );
2727
var incrmstdev = require( '@stdlib/stats/incr/mstdev' );
28+
var incrmmax = require( '@stdlib/stats/incr/mmax' );
2829

2930

3031
// MAIN //
@@ -44,6 +45,7 @@ function incrmsummary( W ) {
4445
var summary;
4546
var mstdev;
4647
var mmean;
48+
var mmax;
4749
var msum;
4850
if ( !isPositiveInteger( W ) ) {
4951
throw new TypeError( 'invalid input argument. Must provide a positive integer. Value: `' + W + '`.' );
@@ -52,6 +54,7 @@ function incrmsummary( W ) {
5254
mstdev = incrmstdev( W );
5355
mmean = incrmmean( W );
5456
msum = incrmsum( W );
57+
mmax = incrmmax( W );
5558
summary = {};
5659

5760
return accumulator;
@@ -85,6 +88,7 @@ function incrmsummary( W ) {
8588
summary.mean = mmean( x );
8689
summary.variance = mvariance( x );
8790
summary.stdev = mstdev( x );
91+
summary.max = mmax( x );
8892
return summary;
8993
}
9094
}

lib/node_modules/@stdlib/stats/incr/msummary/test/test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ tape( 'the accumulator function incrementally computes a moving summary', functi
9595
'sum': 11.0,
9696
'mean': 3.666666666666666666,
9797
'variance': 0.3333333333333339,
98-
'stdev': 0.5773502691896263
98+
'stdev': 0.5773502691896263,
99+
'max': 4.0
99100
};
100101
t.deepEqual( actual[ N-1 ], expected, 'returns expected incremental results' );
101102
t.deepEqual( acc(), expected, 'returns expected incremental results' );

0 commit comments

Comments
 (0)