New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

peaks-similarity

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

peaks-similarity

Peaks similarity - calculate the similarity between 2 ordered arrays of peaks

  • 3.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
184
increased by166.67%
Maintainers
3
Weekly downloads
 
Created
Source

peaks-similarity

NPM version [![build status][travis-image]][travis-url] [![David deps][david-image]][david-url] npm download

Peaks similarity - calculate a similarity between 0 and 1 of 2 arrays of [x,y] points.

Description

The idea is to calculate a similarity value between 0 and 1 between two arrays of peaks ([x,y] points).

const peaks1 = [
  [1, 1],
  [2, 2],
];
const peaks2 = [
  [1, 2],
  [2, 1],
];

import Comparator from 'peaks-similarity';
const comparator = new Comparator({ widthBottom: 4, widthTop: 2 });
const result = comparator.getSimilarity(peaks1, peaks2);

console.log(result);

options

  • widthBottom : bottom width of the trapezoid (default: 2)
  • widthTop : top width of the trapezoid (default: 1)
  • trapezoid : Should we use overlapping of trapezoids surface (default: false). If trapezoid is false it is based only on peaks and not surface.
  • common: Only take the common part of the array based on the widthBottom of the trapezoid (default: false)
    • true: take the common part between the 2 array
    • first: keep first array and take the common part of the second one
    • second: keep second array and take the common part of the first one

Methods

  • setOptions(newOptions)
  • setPeaks1(anArray)
  • setPeaks2(anArray)
  • getExtract1()
  • getExtract2()
  • getExtractInfo1()
  • getExtractInfo2()
  • setTrapezoid(newWidthBottom, newWidthTop)
  • setFromTo(newFrom, newTo)
  • getOverlap(x1, y1, x2, y2)
  • getOverlapTrapezoid(x1, y1, x2, y2)
  • calculateDiff()
  • checkArray(points)
  • getSimilarity(newPeaks1, newPeaks2)
  • fastSimilarity(newPeaks2, from, to)
    • newPeaks2 has to be normalized (sum to 1)
    • fastSimilarity will use the common parameter. This parameter may be 'second' and will take the peaks1 that are at a distance less than widthBottom of any peak of peaks2

License

MIT

Keywords

FAQs

Package last updated on 30 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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