@@ -54,9 +54,9 @@ function mean( out, arr ) {
5454 N = 0 ;
5555 for ( i = 0 ; i < arr . length ; i ++ ) {
5656 N += 1 ;
57- delta = arr [ i ] [ 0 ] - mx ;
57+ delta = arr [ i ] [ 0 ] - mx ;
5858 mx += delta / N ;
59- delta = arr [ i ] [ 1 ] - my ;
59+ delta = arr [ i ] [ 1 ] - my ;
6060 my += delta / N ;
6161 }
6262 out [ 0 ] = mx ;
@@ -88,9 +88,9 @@ function stdev( out, arr, mx, my, bool ) {
8888 N = 0 ;
8989 for ( i = 0 ; i < arr . length ; i ++ ) {
9090 N += 1 ;
91- delta = arr [ i ] [ 0 ] - mx ;
91+ delta = arr [ i ] [ 0 ] - mx ;
9292 M2x += delta * delta ;
93- delta = arr [ i ] [ 1 ] - my ;
93+ delta = arr [ i ] [ 1 ] - my ;
9494 M2y += delta * delta ;
9595 }
9696 if ( bool ) {
@@ -103,8 +103,8 @@ function stdev( out, arr, mx, my, bool ) {
103103 out [ 1 ] = 0.0 ;
104104 return out ;
105105 }
106- out [ 0 ] = sqrt ( M2x / ( N - 1 ) ) ;
107- out [ 1 ] = sqrt ( M2y / ( N - 1 ) ) ;
106+ out [ 0 ] = sqrt ( M2x / ( N - 1 ) ) ;
107+ out [ 1 ] = sqrt ( M2y / ( N - 1 ) ) ;
108108 return out ;
109109}
110110
@@ -126,15 +126,15 @@ function covariance( arr, mx, my, bool ) {
126126 N = arr . length ;
127127 C = 0.0 ;
128128 for ( i = 0 ; i < N ; i ++ ) {
129- C += ( arr [ i ] [ 0 ] - mx ) * ( arr [ i ] [ 1 ] - my ) ;
129+ C += ( arr [ i ] [ 0 ] - mx ) * ( arr [ i ] [ 1 ] - my ) ;
130130 }
131131 if ( bool ) {
132132 return C / N ;
133133 }
134134 if ( N === 1 ) {
135135 return 0.0 ;
136136 }
137- return C / ( N - 1 ) ;
137+ return C / ( N - 1 ) ;
138138}
139139
140140/**
@@ -156,7 +156,7 @@ function pcorrdist( arr, mx, my, bool ) {
156156 }
157157 sd = stdev ( [ 0.0 , 0.0 ] , arr , mx , my , bool ) ;
158158 cov = covariance ( arr , mx , my , bool ) ;
159- d = 1.0 - ( cov / ( sd [ 0 ] * sd [ 1 ] ) ) ;
159+ d = 1.0 - ( cov / ( sd [ 0 ] * sd [ 1 ] ) ) ;
160160 if ( d < 0.0 ) {
161161 return 0.0 ;
162162 }
@@ -183,7 +183,7 @@ function nandatasets( N, M, seed ) {
183183 var j ;
184184
185185 rand = randu . factory ( {
186- 'seed' : seed || ( randu ( ) * pow ( 2.0 , 31 ) ) | 0
186+ 'seed' : seed || ( randu ( ) * pow ( 2.0 , 31 ) ) | 0
187187 } ) ;
188188
189189 // Generate datasets consisting of (x,y) pairs of varying value ranges, where some of the pairs may contain `(NaN, y)`, `(x, NaN)`, or `(NaN, NaN)`...
@@ -229,7 +229,7 @@ tape( 'the function throws an error if not provided a positive integer for the w
229229 ] ;
230230
231231 for ( i = 0 ; i < values . length ; i ++ ) {
232- t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
232+ t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
233233 }
234234 t . end ( ) ;
235235
@@ -259,7 +259,7 @@ tape( 'the function throws an error if not provided a positive integer for the w
259259 ] ;
260260
261261 for ( i = 0 ; i < values . length ; i ++ ) {
262- t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
262+ t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
263263 }
264264 t . end ( ) ;
265265
@@ -286,7 +286,7 @@ tape( 'the function throws an error if not provided a number as the mean value',
286286 ] ;
287287
288288 for ( i = 0 ; i < values . length ; i ++ ) {
289- t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
289+ t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
290290 }
291291 t . end ( ) ;
292292
@@ -313,7 +313,7 @@ tape( 'the function throws an error if not provided a number as the mean value',
313313 ] ;
314314
315315 for ( i = 0 ; i < values . length ; i ++ ) {
316- t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
316+ t . throws ( badValue ( values [ i ] ) , TypeError , 'throws an error when provided ' + values [ i ] ) ;
317317 }
318318 t . end ( ) ;
319319
@@ -324,14 +324,14 @@ tape( 'the function throws an error if not provided a number as the mean value',
324324 }
325325} ) ;
326326
327- tape ( 'the function properly ignores NaN values in x and y inputs' , function test ( t ) {
327+ tape ( 'the function properly ignores NaN values in x and y inputs' , function test ( t ) {
328328 var result ;
329329 var acc ;
330330
331- acc = incrnanmpcorrdist ( 3 , 3.14 , 0.0 ) ;
331+ acc = incrnanmpcorrdist ( 3 , 3.14 , 0.0 ) ;
332332 result = acc ( ) ;
333333
334- t . ok ( ! isnan ( result ) , 'result should not be NaN' ) ;
334+ t . ok ( ! isnan ( result ) , 'result should not be NaN' ) ;
335335 t . end ( ) ;
336336} ) ;
337337
@@ -367,7 +367,7 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment
367367 M = 100 ;
368368 data = nandatasets ( N , M , randu . seed ) ;
369369
370- t . pass ( 'seed: ' + randu . seed ) ;
370+ t . pass ( 'seed: ' + randu . seed ) ;
371371
372372 // Define the window size:
373373 W = 10 ;
@@ -379,14 +379,14 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment
379379 acc = incrnanmpcorrdist ( W ) ;
380380 countNonNanPairs = 0 ;
381381 for ( j = 0 ; j < M ; j ++ ) {
382- actual = acc ( d [ j ] [ 0 ] , d [ j ] [ 1 ] ) ;
383- countNonNanPairs += ( ! isnan ( d [ j ] [ 0 ] ) && ! isnan ( d [ j ] [ 1 ] ) ) ? 1 : 0 ;
382+ actual = acc ( d [ j ] [ 0 ] , d [ j ] [ 1 ] ) ;
383+ countNonNanPairs += ( ! isnan ( d [ j ] [ 0 ] ) && ! isnan ( d [ j ] [ 1 ] ) ) ? 1 : 0 ;
384384
385385 arr = [ ] ;
386386 k = j ;
387- while ( arr . length < min ( countNonNanPairs , W ) && k >= 0 ) {
388- if ( ! isnan ( d [ k ] [ 0 ] ) && ! isnan ( d [ k ] [ 1 ] ) ) {
389- arr . push ( d [ k ] ) ;
387+ while ( arr . length < min ( countNonNanPairs , W ) && k >= 0 ) {
388+ if ( ! isnan ( d [ k ] [ 0 ] ) && ! isnan ( d [ k ] [ 1 ] ) ) {
389+ arr . push ( d [ k ] ) ;
390390 }
391391 k -= 1 ;
392392 }
@@ -404,7 +404,7 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment
404404 }
405405
406406 if ( actual === expected ) {
407- t . equal ( actual , expected , 'returns expected value. dataset: ' + i + '. window: ' + j + '.' ) ;
407+ t . equal ( actual , expected , 'returns expected value. dataset: ' + i + '. window: ' + j + '.' ) ;
408408 } else {
409409 if ( actual < 0.0 ) {
410410 actual = 0.0 ; // NOTE: this addresses occasional negative values due to accumulated floating-point error. Based on observation, typically `|actual| ≅ |expected|`, but `actual < 0` and `expected > 0`, suggesting that a sign got "flipped" along the way due to, e.g., operations which theoretically should compute to the same value, but do not due to floating-point error.
@@ -415,7 +415,7 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment
415415 } else {
416416 tol = 1.0e6 * EPS * abs ( expected ) ;
417417 }
418- t . equal ( delta <= tol , true , 'dataset: ' + i + '. window: ' + j + '. expected: ' + expected + '. actual: ' + actual + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
418+ t . equal ( delta <= tol , true , 'dataset: ' + i + '. window: ' + j + '. expected: ' + expected + '. actual: ' + actual + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
419419 }
420420 }
421421 }
@@ -445,14 +445,14 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment
445445 M = 100 ;
446446 data = nandatasets ( N , M , randu . seed ) ;
447447
448- t . pass ( 'seed: ' + randu . seed ) ;
448+ t . pass ( 'seed: ' + randu . seed ) ;
449449
450450 // Define the window size:
451451 W = 10 ;
452452
453453 // For each dataset, compute the actual and expected correlation distances...
454- function isNotNaN ( pair ) {
455- return ! isnan ( pair [ 0 ] ) && ! isnan ( pair [ 1 ] ) ;
454+ function isNotNaN ( pair ) {
455+ return ! isnan ( pair [ 0 ] ) && ! isnan ( pair [ 1 ] ) ;
456456 }
457457 for ( i = 0 ; i < N ; i ++ ) {
458458 d = data [ i ] ;
@@ -465,14 +465,14 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment
465465 acc = incrnanmpcorrdist ( W , means [ 0 ] , means [ 1 ] ) ;
466466 countNonNanPairs = 0 ;
467467 for ( j = 0 ; j < M ; j ++ ) {
468- actual = acc ( d [ j ] [ 0 ] , d [ j ] [ 1 ] ) ;
469- countNonNanPairs += ( ! isnan ( d [ j ] [ 0 ] ) && ! isnan ( d [ j ] [ 1 ] ) ) ? 1 : 0 ;
468+ actual = acc ( d [ j ] [ 0 ] , d [ j ] [ 1 ] ) ;
469+ countNonNanPairs += ( ! isnan ( d [ j ] [ 0 ] ) && ! isnan ( d [ j ] [ 1 ] ) ) ? 1 : 0 ;
470470
471471 arr = [ ] ;
472472 k = j ;
473- while ( arr . length < min ( countNonNanPairs , W ) && k >= 0 ) {
474- if ( ! isnan ( d [ k ] [ 0 ] ) && ! isnan ( d [ k ] [ 1 ] ) ) {
475- arr . push ( d [ k ] ) ;
473+ while ( arr . length < min ( countNonNanPairs , W ) && k >= 0 ) {
474+ if ( ! isnan ( d [ k ] [ 0 ] ) && ! isnan ( d [ k ] [ 1 ] ) ) {
475+ arr . push ( d [ k ] ) ;
476476 }
477477 k -= 1 ;
478478 }
@@ -484,11 +484,11 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment
484484 }
485485
486486 if ( actual === expected ) {
487- t . equal ( actual , expected , 'returns expected value. dataset: ' + i + '. window: ' + j + '.' ) ;
487+ t . equal ( actual , expected , 'returns expected value. dataset: ' + i + '. window: ' + j + '.' ) ;
488488 } else {
489489 delta = abs ( actual - expected ) ;
490490 tol = 1.0e6 * EPS * abs ( expected ) ;
491- t . equal ( delta <= tol , true , 'dataset: ' + i + '. window: ' + j + '. expected: ' + expected + '. actual: ' + actual + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
491+ t . equal ( delta <= tol , true , 'dataset: ' + i + '. window: ' + j + '. expected: ' + expected + '. actual: ' + actual + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
492492 }
493493 }
494494 }
@@ -523,13 +523,13 @@ tape( 'if not provided an input value, the accumulator function returns the curr
523523 for ( i = 0 ; i < N ; i ++ ) {
524524 acc ( data [ i ] [ 0 ] , data [ i ] [ 1 ] ) ;
525525 actual = acc ( ) ;
526- if ( i < W - 1 ) {
527- d = data . slice ( 0 , i + 1 ) ;
526+ if ( i < W - 1 ) {
527+ d = data . slice ( 0 , i + 1 ) ;
528528 } else {
529- d = data . slice ( i - W + 1 , i + 1 ) ;
529+ d = data . slice ( i - W + 1 , i + 1 ) ;
530530 }
531- d = d . filter ( function isNotNaN ( pair ) {
532- return ! isnan ( pair [ 0 ] ) && ! isnan ( pair [ 1 ] ) ;
531+ d = d . filter ( function isNotNaN ( pair ) {
532+ return ! isnan ( pair [ 0 ] ) && ! isnan ( pair [ 1 ] ) ;
533533 } ) ;
534534
535535 if ( d . length > 0 ) {
@@ -543,11 +543,11 @@ tape( 'if not provided an input value, the accumulator function returns the curr
543543 }
544544
545545 if ( actual === expected ) {
546- t . equal ( actual , expected , 'returns expected value. window: ' + i + '.' ) ;
546+ t . equal ( actual , expected , 'returns expected value. window: ' + i + '.' ) ;
547547 } else {
548548 delta = abs ( actual - expected ) ;
549549 tol = 1.0 * EPS * abs ( expected ) ;
550- t . equal ( delta < tol , true , 'window: ' + i + '. expected: ' + expected + '. actual: ' + actual + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
550+ t . equal ( delta < tol , true , 'window: ' + i + '. expected: ' + expected + '. actual: ' + actual + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
551551 }
552552 }
553553 t . end ( ) ;
@@ -575,8 +575,8 @@ tape( 'if not provided an input value, the accumulator function returns the curr
575575 ] ;
576576
577577 N = data . length ;
578- function isNotNaN ( pair ) {
579- return ! isnan ( pair [ 0 ] ) && ! isnan ( pair [ 1 ] ) ;
578+ function isNotNaN ( pair ) {
579+ return ! isnan ( pair [ 0 ] ) && ! isnan ( pair [ 1 ] ) ;
580580 }
581581 filteredArr = data . filter ( isNotNaN ) ;
582582 if ( filteredArr . length > 0 ) {
@@ -592,14 +592,14 @@ tape( 'if not provided an input value, the accumulator function returns the curr
592592 for ( i = 0 ; i < N ; i ++ ) {
593593 acc ( data [ i ] [ 0 ] , data [ i ] [ 1 ] ) ;
594594 actual = acc ( ) ;
595- if ( i < W - 1 ) {
596- d = data . slice ( 0 , i + 1 ) ;
595+ if ( i < W - 1 ) {
596+ d = data . slice ( 0 , i + 1 ) ;
597597 } else {
598- d = data . slice ( i - W + 1 , i + 1 ) ;
598+ d = data . slice ( i - W + 1 , i + 1 ) ;
599599 }
600600
601- d = d . filter ( function isNotNaN ( pair ) {
602- return ! isnan ( pair [ 0 ] ) && ! isnan ( pair [ 1 ] ) ;
601+ d = d . filter ( function isNotNaN ( pair ) {
602+ return ! isnan ( pair [ 0 ] ) && ! isnan ( pair [ 1 ] ) ;
603603 } ) ;
604604 if ( means === null ) {
605605 expected = null ;
@@ -608,11 +608,11 @@ tape( 'if not provided an input value, the accumulator function returns the curr
608608 }
609609
610610 if ( actual === expected ) {
611- t . equal ( actual , expected , 'returns expected value. window: ' + i + '.' ) ;
611+ t . equal ( actual , expected , 'returns expected value. window: ' + i + '.' ) ;
612612 } else {
613613 delta = abs ( actual - expected ) ;
614614 tol = 1.0 * EPS * abs ( expected ) ;
615- t . equal ( delta < tol , true , 'window: ' + i + '. expected: ' + expected + '. actual: ' + actual + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
615+ t . equal ( delta < tol , true , 'window: ' + i + '. expected: ' + expected + '. actual: ' + actual + '. tol: ' + tol + '. delta: ' + delta + '.' ) ;
616616 }
617617 }
618618 t . end ( ) ;
@@ -651,7 +651,7 @@ tape( 'if the window size is `1` and the means are unknown, the accumulator func
651651
652652 acc = incrnanmpcorrdist ( 1 ) ;
653653 for ( i = 0 ; i < 100 ; i ++ ) {
654- r = acc ( randu ( ) * 100.0 , randu ( ) * 100.0 ) ;
654+ r = acc ( randu ( ) * 100.0 , randu ( ) * 100.0 ) ;
655655 t . equal ( r , 1.0 , 'returns expected value' ) ;
656656 }
657657 t . end ( ) ;
@@ -664,7 +664,7 @@ tape( 'if the window size is `1` and the means are known, the accumulator functi
664664
665665 acc = incrnanmpcorrdist ( 1 , 500.0 , - 500.0 ) ; // means are outside the range of simulated values so the correlation should never be zero
666666 for ( i = 0 ; i < 100 ; i ++ ) {
667- r = acc ( randu ( ) * 100.0 , randu ( ) * 100.0 ) ;
667+ r = acc ( randu ( ) * 100.0 , randu ( ) * 100.0 ) ;
668668 t . notEqual ( r , 1.0 , 'does not return 1' ) ;
669669 }
670670 t . end ( ) ;
0 commit comments