File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
lib/node_modules/@stdlib/stats/incr/nanrmse/test Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -60,14 +60,15 @@ tape( 'the accumulator function incrementally computes the root mean squared err
6060 var x ;
6161 var y ;
6262 var i ;
63+ var c ;
6364
6465 data = [
6566 [ 2.0 , 3.0 ] ,
6667 [ 3.0 , - 1.0 ] ,
6768 [ 2.0 , 5.0 ] ,
68- [ NaN , 2.0 ] ,
69- [ 4.0 , - 4.0 ] ,
7069 [ 1.0 , NaN ] ,
70+ [ 4.0 , - 4.0 ] ,
71+ [ NaN , 2.0 ] ,
7172 [ 3.0 , 0.0 ] ,
7273 [ - 4.0 , 5.0 ]
7374 ] ;
@@ -76,14 +77,18 @@ tape( 'the accumulator function incrementally computes the root mean squared err
7677 acc = incrnanrmse ( ) ;
7778
7879 sum = 0 ;
80+ c = 0 ;
7981 for ( i = 0 ; i < N ; i ++ ) {
8082 x = data [ i ] [ 0 ] ;
8183 y = data [ i ] [ 1 ] ;
82- if ( isnan ( d ) === false ) {
84+ if ( isnan ( x ) === false && isnan ( y ) === false ) {
8385 r = y - x ;
8486 sum += r * r ;
87+ c += 1 ;
88+ expected = sqrt ( sum / c ) ;
89+ } else {
90+ expected = sqrt ( sum / c ) ;
8591 }
86- expected = sqrt ( sum / ( i + 1 ) ) ;
8792 actual = acc ( x , y ) ;
8893 if ( actual === expected ) {
8994 t . equal ( actual , expected , 'returns expected value' ) ;
You can’t perform that action at this time.
0 commit comments