Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ml-savitzky-golay-generalized

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-savitzky-golay-generalized - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

8

package.json
{
"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);
}
*/
´´´
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc