ashvardanian / SimSIMD

Up to 200x Faster Dot Products & Similarity Metrics — for Python, Rust, C, JS, and Swift, supporting f64, f32, f16 real & complex, i8, and bit vectors using SIMD for both AVX2, AVX-512, NEON, SVE, & SVE2 📐
https://ashvardanian.com/posts/simsimd-faster-scipy/
Apache License 2.0
988 stars 59 forks source link

Add covariance estimator #140

Open amirzia opened 5 months ago

amirzia commented 5 months ago

Ref: #90

amirzia commented 5 months ago

@ashvardanian Does the algorithm look good to you? If so, I'll proceed with implementing the same for other archs.

ashvardanian commented 5 months ago

The code looks good, but looking at it, two passes over data look expensive. I'd assume a lot of people would pre-normalized series if they want to search them, and in that case they would simply call the dot product and divide the result. What do you think might be more useful - covariance, RMSD, or maybe Pearson correlation, @amirzia?

amirzia commented 5 months ago

I found the single-pass version of covariance estimator, which I can implement.

I think among these, the Pearson correlation and then covariance are the most useful. In case the data is normalized the covariance and correlation are the same and they can be easily calculated.

I think still many people work with unnormalized data and having covariance or correlation estimators is valuable. For example, I found these two instances where libraries need to calculate covariance between two time series without assuming that data is normalized:

How do you think we should proceed?

Btw, we can add regression error metrics (RMSE, MAPE, ...) to simsimd. They're common in ML and time-series analysis.

ashvardanian commented 2 months ago

Just leaving this here for future research - heal-research/vstat 🤗