Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: linear interpolation for mean #225

Closed
Inspirateur opened this issue Aug 9, 2019 · 2 comments
Closed

Feature Request: linear interpolation for mean #225

Inspirateur opened this issue Aug 9, 2019 · 2 comments

Comments

@Inspirateur
Copy link

Inspirateur commented Aug 9, 2019

So I recently discovered this nice library and decided to try it since I got unevenly spaced data,
however I found out today that the .mean() wasn't doing linear interpolation as I thought it would be:

>>> from traces import TimeSeries
>>> t = TimeSeries()
>>> t[0] = 0
>>> t[1] = 0
>>> t[3] = 20
>>> t.mean(0, 2)
0.0

With linear interpolation between 2 points we would find that t[2] = 10 and doing the average from 0 to 2 would give us 3.333 in this example.
A simple optional argument in mean() to choose the interpolation method would be fantastic, and I really think that it would be useful to many users who are not using traces exclusively for binary data (where linear interpolation would make no sense).
I know that we can re-sample the TimeSeries but I think a shortcut like this would be really neat since this library is designed with ease of use in mind.

Thanks for reading and have a nice day 👋

@stringertheory
Copy link
Owner

@Inspirateur thanks for the suggestion! I agree this would be useful. To double check I'm understanding, in the example you gave the mean between 0 and 2 should be 2.5, right? (and 3.333 if taken between 0 and 3?)

image

@stringertheory
Copy link
Owner

added this in 05a1460

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants