SimSIMD icon indicating copy to clipboard operation
SimSIMD copied to clipboard

Add covariance estimator

Open amirzia opened this issue 1 year ago • 4 comments

Ref: #90

amirzia avatar Jun 12 '24 21:06 amirzia

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

amirzia avatar Jun 12 '24 21:06 amirzia

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?

ashvardanian avatar Jun 12 '24 22:06 ashvardanian

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:

  • https://github.com/facebookresearch/Kats/blob/635fef8d04095a56958377055a65f2ba67b27cec/kats/detectors/detector_consts.py#L481
  • https://github.com/StingraySoftware/stingray/blob/main/stingray/covariancespectrum.py#L422

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.

amirzia avatar Jun 13 '24 18:06 amirzia

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

ashvardanian avatar Aug 26 '24 17:08 ashvardanian