RicardoSantos

SimilarityMeasures

Library "SimilarityMeasures"
Similarity measures are statistical methods used to quantify the distance between different data sets
or strings. There are various types of similarity measures, including those that compare:
- data points (SSD, Euclidean, Manhattan, Minkowski, Chebyshev, Correlation, Cosine, Camberra, MAE, MSE, Lorentzian, Intersection, Penrose Shape, Meehl),
- strings (Edit(Levenshtein), Lee, Hamming, Jaro),
- probability distributions (Mahalanobis, Fidelity, Bhattacharyya, Hellinger),
- sets (Kumar Hassebrook, Jaccard, Sorensen, Chi Square).
---
These measures are used in various fields such as data analysis, machine learning, and pattern recognition. They
help to compare and analyze similarities and differences between different data sets or strings, which
can be useful for making predictions, classifications, and decisions.
---
References:
en.wikipedia.org/wik...i/Similarity_measure
cran.r-project.org/w...yMeasures/index.html
numerics.mathdotnet.com/Distance
github.com/ngmarchant/comparator
github.com/drostlab/...74fb/src/distances.h
github.com/scipy/sci.../spatial/distance.py
Encyclopedia of Distances, doi.org/10.1007/978-3-662-52844-0

ssd(p, q)
  Sum of squared difference for N dimensions.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Measure of distance that calculates the squared euclidean distance.

euclidean(p, q)
  Euclidean distance for N dimensions.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Measure of distance that calculates the straight-line (or Euclidean).

manhattan(p, q)
  Manhattan distance for N dimensions.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Measure of absolute differences between both points.

minkowski(p, q, p_value)
  Minkowsky Distance for N dimensions.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
    p_value (float): `float` P value, default=1.0(1: manhatan, 2: euclidean), does not support chebychev.
  Returns: Measure of similarity in the normed vector space.

chebyshev(p, q)
  Chebyshev distance for N dimensions.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Measure of maximum absolute difference.

correlation(p, q)
  Correlation distance for N dimensions.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Measure of maximum absolute difference.

cosine(p, q)
  Cosine distance between provided vectors.
  Parameters:
    p (float): `array<float>` 1D Vector.
    q (float): `array<float>` 1D Vector.
  Returns: The Cosine distance between vectors `p` and `q`.

---
angiogenesis.dkfz.de...cs_clust/cluster.htm

camberra(p, q)
  Camberra distance for N dimensions.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Weighted measure of absolute differences between both points.

mae(p, q)
  Mean absolute error is a normalized version of the sum of absolute difference (manhattan).
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Mean absolute error of vectors `p` and `q`.

mse(p, q)
  Mean squared error is a normalized version of the sum of squared difference.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Mean squared error of vectors `p` and `q`.

lorentzian(p, q)
  Lorentzian distance between provided vectors.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Lorentzian distance of vectors `p` and `q`.

---
angiogenesis.dkfz.de...cs_clust/cluster.htm

intersection(p, q)
  Intersection distance between provided vectors.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Intersection distance of vectors `p` and `q`.

---
angiogenesis.dkfz.de...cs_clust/cluster.htm

penrose(p, q)
  Penrose Shape distance between provided vectors.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Penrose shape distance of vectors `p` and `q`.

---
angiogenesis.dkfz.de...cs_clust/cluster.htm

meehl(p, q)
  Meehl distance between provided vectors.
  Parameters:
    p (float): `array<float>` Vector with first numeric distribution.
    q (float): `array<float>` Vector with second numeric distribution.
  Returns: Meehl distance of vectors `p` and `q`.

---
angiogenesis.dkfz.de...cs_clust/cluster.htm

edit(x, y)
  Edit (aka Levenshtein) distance for indexed strings.
  Parameters:
    x (int): `array<int>` Indexed array.
    y (int): `array<int>` Indexed array.
  Returns: Number of deletions, insertions, or substitutions required to transform source string into target string.

---
generated description:
The Edit distance is a measure of similarity used to compare two strings. It is defined as the minimum number of
operations (insertions, deletions, or substitutions) required to transform one string into another. The operations
are performed on the characters of the strings, and the cost of each operation depends on the specific algorithm
used.
The Edit distance is widely used in various applications such as spell checking, text similarity, and machine
translation. It can also be used for other purposes like finding the closest match between two strings or
identifying the common prefixes or suffixes between them.

---
github.com/disha2sin...ing/EditDistance.cpp
www.red-gate.com/sim...venshtein-algorithm/
planetcalc.com/1721/

lee(x, y, dsize)
  Distance between two indexed strings of equal length.
  Parameters:
    x (int): `array<int>` Indexed array.
    y (int): `array<int>` Indexed array.
    dsize (int): `int` Dictionary size.
  Returns: Distance between two strings by accounting for dictionary size.

---
www.johndcook.com/bl...nce-codes-and-music/

hamming(x, y)
  Distance between two indexed strings of equal length.
  Parameters:
    x (int): `array<int>` Indexed array.
    y (int): `array<int>` Indexed array.
  Returns: Length of different components on both sequences.

---
en.wikipedia.org/wiki/Hamming_distance

jaro(x, y)
  Distance between two indexed strings.
  Parameters:
    x (int): `array<int>` Indexed array.
    y (int): `array<int>` Indexed array.
  Returns: Measure of two strings' similarity: the higher the value, the more similar the strings are.
The score is normalized such that `0` equates to no similarities and `1` is an exact match.

---
rosettacode.org/wiki/Jaro_similarity

mahalanobis(p, q, VI)
  Mahalanobis distance between two vectors with population inverse covariance matrix.
  Parameters:
    p (float): `array<float>` 1D Vector.
    q (float): `array<float>` 1D Vector.
    VI (matrix<float>): `matrix<float>` Inverse of the covariance matrix.
  Returns: The mahalanobis distance between vectors `p` and `q`.

---
people.revoledu.com/...lanobisDistance.html
stat.ethz.ch/R-manua...tml/mahalanobis.html
docs.scipy.org/doc/s...nce.mahalanobis.html

fidelity(p, q)
  Fidelity distance between provided vectors.
  Parameters:
    p (float): `array<float>` 1D Vector.
    q (float): `array<float>` 1D Vector.
  Returns: The Bhattacharyya Coefficient between vectors `p` and `q`.

---
en.wikipedia.org/wik...ty_of_quantum_states

bhattacharyya(p, q)
  Bhattacharyya distance between provided vectors.
  Parameters:
    p (float): `array<float>` 1D Vector.
    q (float): `array<float>` 1D Vector.
  Returns: The Bhattacharyya distance between vectors `p` and `q`.

---
en.wikipedia.org/wik...attacharyya_distance

hellinger(p, q)
  Hellinger distance between provided vectors.
  Parameters:
    p (float): `array<float>` 1D Vector.
    q (float): `array<float>` 1D Vector.
  Returns: The hellinger distance between vectors `p` and `q`.

---
en.wikipedia.org/wik...i/Hellinger_distance
jamesmccaffrey.wordp...utions-using-python/

kumar_hassebrook(p, q)
  Kumar Hassebrook distance between provided vectors.
  Parameters:
    p (float): `array<float>` 1D Vector.
    q (float): `array<float>` 1D Vector.
  Returns: The Kumar Hassebrook distance between vectors `p` and `q`.

---
github.com/drostlab/...74fb/src/distances.h

jaccard(p, q)
  Jaccard distance between provided vectors.
  Parameters:
    p (float): `array<float>` 1D Vector.
    q (float): `array<float>` 1D Vector.
  Returns: The Jaccard distance between vectors `p` and `q`.

---
github.com/drostlab/...74fb/src/distances.h

sorensen(p, q)
  Sorensen distance between provided vectors.
  Parameters:
    p (float): `array<float>` 1D Vector.
    q (float): `array<float>` 1D Vector.
  Returns: The Sorensen distance between vectors `p` and `q`.

---
people.revoledu.com/...yCurtisDistance.html

chi_square(p, q, eps)
  Chi Square distance between provided vectors.
  Parameters:
    p (float): `array<float>` 1D Vector.
    q (float): `array<float>` 1D Vector.
    eps (float)
  Returns: The Chi Square distance between vectors `p` and `q`.

---
uw.pressbooks.pub/ap...r/distance-measures/
stats.stackexchange....-chi-square-distance
www.itl.nist.gov/div.../section3/eda35f.htm

kulczynsky(p, q, eps)
  Kulczynsky distance between provided vectors.
  Parameters:
    p (float): `array<float>` 1D Vector.
    q (float): `array<float>` 1D Vector.
    eps (float)
  Returns: The Kulczynsky distance between vectors `p` and `q`.

---
github.com/drostlab/...74fb/src/distances.h
Thư viện Pine

Với tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác từ cộng đồng của chúng tôi có thể sử dụng lại nó. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này một cách riêng tư hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy chung.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng thư viện này?

Sao chép văn bản vào khay nhớ tạm và dán nó vào tập lệnh của bạn.