compute-incrmmean
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,29 +0,1 @@ | ||
/** | ||
* | ||
* COMPUTE: incrmmean | ||
* | ||
* | ||
* DESCRIPTION: | ||
* - Provides a method to compute a moving arithmetic mean incrementally. | ||
* | ||
* | ||
* NOTES: | ||
* [1] | ||
* | ||
* | ||
* TODO: | ||
* [1] | ||
* | ||
* | ||
* LICENSE: | ||
* MIT | ||
* | ||
* Copyright (c) 2014. Athan Reines. | ||
* | ||
* | ||
* AUTHOR: | ||
* Athan Reines. kgryte@gmail.com. 2014. | ||
* | ||
*/ | ||
'use strict'; | ||
@@ -33,3 +5,3 @@ | ||
var isInteger = require( 'validate.io-integer' ); | ||
var isPositiveInteger = require( 'validate.io-positive-integer' ); | ||
@@ -47,4 +19,4 @@ | ||
function incrmmean( W ) { | ||
if ( !isInteger( W ) || W < 1 ) { | ||
throw new TypeError( 'incrmmean()::invalid input argument. Window size must be a positive integer.' ); | ||
if ( !isPositiveInteger( W ) ) { | ||
throw new TypeError( 'incrmmean()::invalid input argument. Window size must be a positive integer. Value: `' + W + '`.' ); | ||
} | ||
@@ -55,4 +27,3 @@ var arr = new Array( W ), | ||
i = -1, | ||
delta, | ||
tmp; | ||
delta; | ||
/** | ||
@@ -63,3 +34,3 @@ * FUNCTION: incrmmean( [value] ) | ||
* @param {Number} [value] - value used to update the moving mean | ||
* @returns {Number} mean | ||
* @returns {Number|Null} mean or null | ||
*/ | ||
@@ -78,3 +49,2 @@ return function incrmmean( x ) { | ||
if ( N < W ) { | ||
arr[ i ] = x; | ||
N += 1; | ||
@@ -84,7 +54,6 @@ delta = x - mu; | ||
} else { | ||
tmp = arr[ i ]; | ||
arr[ i ] = x; | ||
delta = x - tmp; | ||
delta = x - arr[ i ]; | ||
mu += delta / W; | ||
} | ||
arr[ i ] = x; | ||
return mu; | ||
@@ -91,0 +60,0 @@ }; |
{ | ||
"name": "compute-incrmmean", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Provides a method to compute a moving arithmetic mean incrementally.", | ||
@@ -13,2 +13,6 @@ "author": { | ||
"email": "kgryte@gmail.com" | ||
}, | ||
{ | ||
"name": "Philipp Burckhardt", | ||
"email": "pburckhardt@outlook.com" | ||
} | ||
@@ -40,3 +44,7 @@ ], | ||
"moving average", | ||
"sliding window" | ||
"sliding window", | ||
"arithmetic", | ||
"sliding", | ||
"window", | ||
"moving" | ||
], | ||
@@ -47,7 +55,7 @@ "bugs": { | ||
"dependencies": { | ||
"validate.io-integer": "^1.0.2" | ||
"validate.io-positive-integer": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "1.x.x", | ||
"mocha": "1.x.x", | ||
"chai": "2.x.x", | ||
"mocha": "2.x.x", | ||
"coveralls": "^2.11.1", | ||
@@ -58,8 +66,3 @@ "istanbul": "^0.3.0", | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/MIT" | ||
} | ||
] | ||
"license": "MIT" | ||
} |
@@ -19,4 +19,2 @@ incrmmean | ||
To use the module, | ||
``` javascript | ||
@@ -99,4 +97,2 @@ var incrmmean = require( 'compute-incrmmean' ); | ||
## Tests | ||
@@ -129,12 +125,11 @@ | ||
--- | ||
## License | ||
[MIT license](http://opensource.org/licenses/MIT). | ||
[MIT license](http://opensource.org/licenses/MIT). | ||
--- | ||
## Copyright | ||
Copyright © 2014. Athan Reines. | ||
Copyright © 2014-2015. The Compute.io Authors. | ||
@@ -141,0 +136,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8148
51
151
+ Addedvalidate.io-positive-integer@1.0.0(transitive)
- Removedvalidate.io-integer@^1.0.2