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

ml-spectra-processing

Package Overview
Dependencies
Maintainers
6
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-spectra-processing - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

16

History.md

@@ -0,1 +1,17 @@

# [1.1.0](https://github.com/cheminfo/spectra-processing/compare/v0.6.1...v1.1.0) (2019-12-13)
### Bug Fixes
* export X.getFromToIndex ([39e16c3](https://github.com/cheminfo/spectra-processing/commit/39e16c346031524676b2ef76f94df96ffd2c601a))
### Features
* add optimize in reduce ([b00a6ce](https://github.com/cheminfo/spectra-processing/commit/b00a6cea4d6f263b431f319b405d52bf37ac02df))
* add xyObject ([dcd8c44](https://github.com/cheminfo/spectra-processing/commit/dcd8c445a2909300204e5b1b61d6fcdc6ab0e876))
* export X.findClosestIndex ([f5321b3](https://github.com/cheminfo/spectra-processing/commit/f5321b30652003eb97ac72d38cbaf4d9814ce168))
## [0.6.1](https://github.com/cheminfo/spectra-processing/compare/v0.6.0...v0.6.1) (2019-11-13)

@@ -2,0 +18,0 @@

67

lib/index.js

@@ -871,2 +871,34 @@ 'use strict';

/**
* Calculates the correlation between 2 vectors
* https://en.wikipedia.org/wiki/Correlation_and_dependence
*
* @param {Array} [A] - the array that will be rotated
* @param {Array} [B]
* @return {Array}
*/
function correlation(A, B) {
let n = A.length;
let sumA = 0;
let sumA2 = 0;
let sumB = 0;
let sumB2 = 0;
let sumAB = 0;
for (let i = 0; i < n; i++) {
let a = A[i];
let b = B[i];
sumA += a;
sumA2 += a ** 2;
sumB += b;
sumB2 += b ** 2;
sumAB += a * b;
}
return (
(n * sumAB - sumA * sumB) /
(Math.sqrt(n * sumA2 - sumA ** 2) * Math.sqrt(n * sumB2 - sumB ** 2))
);
}
/**
/**
* This function divide the first array by the second array or a constant value to each element of the first array

@@ -986,39 +1018,9 @@ * @param {Array} array1 - the array that will be rotated

/**
/**
* Calculates the correlation between 2 vectors
* https://en.wikipedia.org/wiki/Correlation_and_dependence
*
* @param {Array} [A] - the array that will be rotated
* @param {Array} [B]
* @return {Array}
*/
function correlation(A, B) {
let n = A.length;
let sumA = 0;
let sumA2 = 0;
let sumB = 0;
let sumB2 = 0;
let sumAB = 0;
for (let i = 0; i < n; i++) {
let a = A[i];
let b = B[i];
sumA += a;
sumA2 += a ** 2;
sumB += b;
sumB2 += b ** 2;
sumAB += a * b;
}
return (
(n * sumAB - sumA * sumB) /
(Math.sqrt(n * sumA2 - sumA ** 2) * Math.sqrt(n * sumB2 - sumB ** 2))
);
}
const X = {
add,
boxPlot,
correlation,
divide,
findClosestIndex,
getFromToIndex,
getTargetIndex,

@@ -1028,3 +1030,2 @@ multiply,

subtract,
correlation,
};

@@ -1031,0 +1032,0 @@

{
"name": "ml-spectra-processing",
"version": "1.0.0",
"version": "1.1.0",
"description": "Various method to process spectra",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

import { add } from './add';
import { boxPlot } from './boxPlot';
import { correlation } from './correlation';
import { divide } from './divide';
import { findClosestIndex } from './findClosestIndex';
import { getFromToIndex } from './getFromToIndex';
import { getTargetIndex } from './getTargetIndex';

@@ -9,3 +11,2 @@ import { multiply } from './multiply';

import { subtract } from './subtract';
import { correlation } from './correlation';

@@ -15,4 +16,6 @@ export const X = {

boxPlot,
correlation,
divide,
findClosestIndex,
getFromToIndex,
getTargetIndex,

@@ -22,3 +25,2 @@ multiply,

subtract,
correlation,
};
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