raw values or distributions as input to wasserstein_distance

[email protected] Wed, 01 Feb 2023 13:14:40 -0000
Newsgroups gmane.comp.python.scientific.user
Message-ID <[email protected]>
I'd like to use the wasserstein_distance function to compute the similarity between two time series (x and y below). The documentation says that the input data are "Values observed in the (empirical) distribution". My data arrays x and y have been standardized to mean 0:

x = array([-1.50849069, -0.38884367, -0.48630848, -0.921818  ,  1.5075886 , -0.07742729,  0.73485371,  0.87245738,  0.11869032, -0.18608133, 1.13576794,  0.59285469, -1.43974886, -1.30714982, -1.48295675, 2.06252624,  0.8560106 , -0.28539087, -0.16960491,  0.37307118])
y = array([-1.58132851, -1.49493426, -0.75626285, -0.37475104,  0.00193676, 1.54513722,  0.77022117,  0.74651951,  0.04927758, -0.41780599, 1.41896231,  0.25463222,  1.06646509, -1.28262476, -2.11766631, 0.92243796,  0.53390812, -0.10711093,  0.35730549,  0.46568122])

I initially thought I should create an empirical distribution of x and y:

from statsmodels.distributions.empirical_distribution import ECDF

ecdf_x = ECDF(x)
x_ecdf = ecdf_y.y

ecdf_y = ECDF(y)
y_ecdf = ecdf_y.y

wasserstein_distance(x_ecdf, y_ecdf)

But an answer in stackoverflow (https://stackoverflow.com/questions/75237101/empirical-distribution-from-data-python) suggests I should simply use the actual data without converting x and y to distributions.

Would you recommend one approach over the other? Are there disadvantages to using the actual data as input to wasserstein_distance?

The tutorials I read so far have always mentioned distributions as input data, not raw values. However, as the SO answer from the link above points out, even the examples in the scipy documentation seem to use raw values.

So I'm a little confused how I should go on with this.
_______________________________________________
SciPy-User mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/scipy-user.python.org/
Member address: [email protected]