peaks-similarity
v3.1.1
Published
Peaks similarity - calculate the similarity between 2 ordered arrays of peaks
Downloads
1,793
Readme
peaks-similarity
[![build status][travis-image]][travis-url] [![David deps][david-image]][david-url]
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