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
5
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 3.0.0 to 4.0.0

19

lib-esm/index.d.ts

@@ -1,9 +0,3 @@

import { DoubleArray } from "cheminfo-types";
/**
* Apply Savitzky Golay algorithm
* @param [ys] Array of y values
* @param [xs] Array of X or deltaX
* @return Array containing the new ys (same length)
*/
export default function SavitzkyGolay(ys: DoubleArray, xs: DoubleArray | number, options?: {
import { DoubleArray } from 'cheminfo-types';
export interface SGGOptions {
/**

@@ -21,3 +15,10 @@ * @default 9

polynomial?: number;
}): Float64Array;
}
/**
* Apply Savitzky Golay algorithm
* @param [ys] Array of y values
* @param [xs] Array of X or deltaX
* @return Array containing the new ys (same length)
*/
export declare function sgg(ys: DoubleArray, xs: DoubleArray | number, options?: SGGOptions): Float64Array;
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import { isAnyArray } from "is-any-array";
import { isAnyArray } from 'is-any-array';
/**

@@ -8,3 +8,3 @@ * Apply Savitzky Golay algorithm

*/
export default function SavitzkyGolay(ys, xs, options = {}) {
export function sgg(ys, xs, options = {}) {
let { windowSize = 9, derivative = 0, polynomial = 3 } = options;

@@ -147,26 +147,2 @@ if (windowSize % 2 === 0 || windowSize < 5 || !Number.isInteger(windowSize)) {

}
/*function entropy(data,h,options){
var trend = SavitzkyGolay(data,h,trendOptions);
var copy = new Array(data.length);
var sum = 0;
var max = 0;
for(var i=0;i<data.length;i++){
copy[i] = data[i]-trend[i];
}
sum/=data.length;
console.log(sum+" "+max);
console.log(stat.array.standardDeviation(copy));
console.log(Math.abs(stat.array.mean(copy))/stat.array.standardDeviation(copy));
return sum;
}
function guessWindowSize(data, h){
console.log("entropy "+entropy(data,h,trendOptions));
return 5;
}
*/
//# sourceMappingURL=index.js.map

@@ -1,9 +0,3 @@

import { DoubleArray } from "cheminfo-types";
/**
* Apply Savitzky Golay algorithm
* @param [ys] Array of y values
* @param [xs] Array of X or deltaX
* @return Array containing the new ys (same length)
*/
export default function SavitzkyGolay(ys: DoubleArray, xs: DoubleArray | number, options?: {
import { DoubleArray } from 'cheminfo-types';
export interface SGGOptions {
/**

@@ -21,3 +15,10 @@ * @default 9

polynomial?: number;
}): Float64Array;
}
/**
* Apply Savitzky Golay algorithm
* @param [ys] Array of y values
* @param [xs] Array of X or deltaX
* @return Array containing the new ys (same length)
*/
export declare function sgg(ys: DoubleArray, xs: DoubleArray | number, options?: SGGOptions): Float64Array;
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sgg = void 0;
const is_any_array_1 = require("is-any-array");

@@ -10,3 +11,3 @@ /**

*/
function SavitzkyGolay(ys, xs, options = {}) {
function sgg(ys, xs, options = {}) {
let { windowSize = 9, derivative = 0, polynomial = 3 } = options;

@@ -82,3 +83,3 @@ if (windowSize % 2 === 0 || windowSize < 5 || !Number.isInteger(windowSize)) {

}
exports.default = SavitzkyGolay;
exports.sgg = sgg;
function getHs(h, center, half, derivative) {

@@ -151,26 +152,2 @@ let hs = 0;

}
/*function entropy(data,h,options){
var trend = SavitzkyGolay(data,h,trendOptions);
var copy = new Array(data.length);
var sum = 0;
var max = 0;
for(var i=0;i<data.length;i++){
copy[i] = data[i]-trend[i];
}
sum/=data.length;
console.log(sum+" "+max);
console.log(stat.array.standardDeviation(copy));
console.log(Math.abs(stat.array.mean(copy))/stat.array.standardDeviation(copy));
return sum;
}
function guessWindowSize(data, h){
console.log("entropy "+entropy(data,h,trendOptions));
return 5;
}
*/
//# sourceMappingURL=index.js.map
{
"name": "ml-savitzky-golay-generalized",
"version": "3.0.0",
"version": "4.0.0",
"description": "Savitzky–Golay filter in Javascript",

@@ -50,18 +50,15 @@ "main": "lib/index.js",

"devDependencies": {
"@types/jest": "^27.0.2",
"eslint": "^7.32.0",
"eslint-config-cheminfo-typescript": "^9.0.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^25.0.5",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.5",
"prettier": "^2.4.1",
"@types/jest": "^27.4.0",
"eslint": "^8.8.0",
"eslint-config-cheminfo-typescript": "^10.3.0",
"jest": "^27.5.1",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.5",
"typescript": "^4.4.4"
"ts-jest": "^27.1.3",
"typescript": "^4.5.5"
},
"dependencies": {
"cheminfo-types": "^0.9.1",
"cheminfo-types": "^0.10.0",
"is-any-array": "^2.0.0"
}
}

@@ -14,4 +14,4 @@ # savitzky-golay-generalized

npm i ml-savitzky-golay-generalized
const SG = require("ml-savitzky-golay-generalized");
SG(dataY, deltaX|X, options)
const {sgg} = require("ml-savitzky-golay-generalized");
sgg(dataY, deltaX|X, options)
```

@@ -47,3 +47,3 @@

```js
var SG = require('ml-savitzky-golay-generalized');
const { sgg } = require('ml-savitzky-golay-generalized');
```

@@ -54,3 +54,3 @@

```js
var options = {
const options = {
windowSize: 15,

@@ -61,10 +61,10 @@ derivative: 0,

var noiseLevel = 0.1;
var data = new Array(200);
for (var i = 0; i < data.length; i++)
const noiseLevel = 0.1;
const data = new Array(200);
for (let 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);
const answer = sgg(data, (Math.PI * 2) / data.length, options);
console.log(answer);
```

@@ -75,3 +75,3 @@

```js
var options = {
const options = {
windowSize: 45,

@@ -82,10 +82,11 @@ derivative: 1,

var noiseLevel = 0.1;
var data = new Array(200);
for (var i = 0; i < data.length; i++)
const noiseLevel = 0.1;
const data = new Array(200);
for (let 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);
}
const answer = sgg(data, (Math.PI * 2) / data.length, options);
console.log(answer);
```

@@ -96,3 +97,3 @@

```js
var options = {
const options = {
windowSize: 47,

@@ -103,6 +104,6 @@ derivative: 1,

var noiseLevel = 0.1;
var data = new Array(200);
var x = new Array(200);
for (var i = 0; i < data.length; i++) {
const noiseLevel = 0.1;
const data = new Array(200);
const x = new Array(200);
for (let i = 0; i < data.length; i++) {
data[i] =

@@ -114,13 +115,4 @@ Math.sin((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);
}
*/
const ans = sgg(data, (Math.PI * 2) / data.length, options);
const ans2 = sgg(data, x, options);
```

@@ -0,4 +1,18 @@

import { DoubleArray } from 'cheminfo-types';
import { isAnyArray } from 'is-any-array';
import { DoubleArray } from "cheminfo-types";
import { isAnyArray } from "is-any-array";
export interface SGGOptions {
/**
* @default 9
*/
windowSize?: number;
/**
* @default 0
*/
derivative?: number;
/**
* @default 3
*/
polynomial?: number;
}

@@ -12,19 +26,6 @@ /**

export default function SavitzkyGolay(
export function sgg(
ys: DoubleArray,
xs: DoubleArray | number,
options: {
/**
* @default 9
*/
windowSize?: number;
/**
* @default 0
*/
derivative?: number;
/**
* @default 3
*/
polynomial?: number;
} = {},
options: SGGOptions = {},
): Float64Array {

@@ -183,26 +184,1 @@ let { windowSize = 9, derivative = 0, polynomial = 3 } = options;

}
/*function entropy(data,h,options){
var trend = SavitzkyGolay(data,h,trendOptions);
var copy = new Array(data.length);
var sum = 0;
var max = 0;
for(var i=0;i<data.length;i++){
copy[i] = data[i]-trend[i];
}
sum/=data.length;
console.log(sum+" "+max);
console.log(stat.array.standardDeviation(copy));
console.log(Math.abs(stat.array.mean(copy))/stat.array.standardDeviation(copy));
return sum;
}
function guessWindowSize(data, h){
console.log("entropy "+entropy(data,h,trendOptions));
return 5;
}
*/

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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