Statistical/Probabilistic Distances

1. Pearson Correlation Coefficient

The Pearson Correlation measures the linear relationship between two variables. It's similar to cosine similarity but works with centered data (mean-subtracted), making it useful for finding linear patterns.

Formula

For two vectors X=(x1,x2,...,xn) and Y=(y1,y2,...,yn):

r=i=1n(xix¯)(yiy¯)i=1n(xix¯)2i=1n(yiy¯)2

Where:

Interpretation:

Relationship to Cosine Similarity:

When to Use:

Advantages:

Disadvantages:

2. Mahalanobis Distance

Mahalanobis Distance (correlated features): Measures the distance between a point and a distribution, taking into account the covariance of the data, making it useful for anomaly detection, clustering, and classification.

Key Properties

Formula:

d(x,μ)=(xμ)TΣ1(xμ)

Where:

How Mahalanobis Distance Accounts for Correlation?

Why Mahalanobis Distance is Better for Clustering in Correlated Data

  1. Handles Correlations:
    • By taking the covariance matrix into account, Mahalanobis distance adjusts the distance based on the interdependencies between features.
  2. Outlier Detection:
    • Mahalanobis distance better identifies outliers, as it recognizes that deviations from the natural direction of the data distribution should result in larger distances.
  3. Elliptical Clusters:
    • Mahalanobis Distance performs well for elliptical clusters, where the data's variance differs along various principal axes.
  4. Density-based Analysis:
    • It detects whether a point lies inside or outside the natural shape of the data distribution, making distances more meaningful.