ml-savitzky-golay-generalized
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "ml-savitzky-golay-generalized", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Savitzky–Golay filter in Javascript", | ||
@@ -15,3 +15,3 @@ "main": "src/index.js", | ||
"type": "git", | ||
"url": "https://github.com/mljs/savitzky-golay" | ||
"url": "https://github.com/mljs/savitzky-golay-generalized" | ||
}, | ||
@@ -32,5 +32,5 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/mljs/savitzky-golay/issues" | ||
"url": "https://github.com/mljs/savitzky-golay-generalized/issues" | ||
}, | ||
"homepage": "https://github.com/mljs/savitzky-golay", | ||
"homepage": "https://github.com/mljs/savitzky-golay-generalized", | ||
"devDependencies": { | ||
@@ -37,0 +37,0 @@ "mocha": "latest", |
@@ -8,1 +8,71 @@ # savitzky-golay-generalized | ||
I'll try an automatic parameter tunning based on the SNR or in the entropy of the signal. | ||
## Examples | ||
´´´ | ||
var SG = require("savitzky-golay-generalized"); | ||
´´´ | ||
### Smoothing example | ||
´´´ | ||
var options = { | ||
windowSize: 15, | ||
derivative: 0, | ||
polynomial: 3 | ||
}; | ||
var noiseLevel = 0.1; | ||
var data = new Array(200); | ||
for (var i = 0; i < data.length; i++) | ||
data[i] = Math.sin(i*Math.PI*2/data.length)+(Math.random()-0.5)*noiseLevel; | ||
var ans = SG(data, Math.PI*2/data.length, options); | ||
console.log(ans); | ||
´´´ | ||
### First derivative test (Equally spaced x) | ||
´´´ | ||
var options = { | ||
windowSize: 47, | ||
derivative: 1, | ||
polynomial: 3 | ||
}; | ||
var noiseLevel = 0.1; | ||
var data = new Array(200); | ||
for (var i = 0; i < data.length; i++) | ||
data[i] = Math.sin(i*Math.PI*2/data.length)+(Math.random()-0.5)*noiseLevel; | ||
var ans = SG(data, Math.PI*2/data.length, options); | ||
console.log(ans); | ||
´´´ | ||
### First derivative test x as vector(It could be non-equally spaced!!) | ||
´´ | ||
var options = { | ||
windowSize: 47, | ||
derivative: 1, | ||
polynomial: 3 | ||
}; | ||
var noiseLevel = 0.1; | ||
var data = new Array(200); | ||
var x = new Array(200); | ||
for (var i = 0; i < data.length; i++){ | ||
data[i] = Math.sin(i*Math.PI*2/data.length)+(Math.random()-0.5)*noiseLevel; | ||
x[i]=i*Math.PI*2/data.length; | ||
} | ||
var ans = SG(data, Math.PI*2/data.length, options); | ||
var ans2 = SG(data, x, options); | ||
/*for (var j = 0; j < data.length; j++){ | ||
console.log(ans[j]+" "+ans2[j]); | ||
}*/ | ||
/* The result should be the approximately the same | ||
for (var j = Math.round(options.windowSize/2); j < data.length-Math.round(options.windowSize/2); j++){ | ||
ans[j].should.be.approximately(ans2[j], 10e-10); | ||
} | ||
*/ | ||
´´´ |
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
11740
78