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

Streaming median #19

Open
kasia-kobalczyk opened this issue Sep 29, 2021 · 2 comments
Open

Streaming median #19

kasia-kobalczyk opened this issue Sep 29, 2021 · 2 comments
Assignees

Comments

@kasia-kobalczyk
Copy link
Collaborator

Implement streaming median (with an optional window).

@kasia-kobalczyk kasia-kobalczyk self-assigned this Sep 29, 2021
@THargreaves
Copy link
Owner

I assume this will be an approximate median? Or at the very least have the option to be.

Exact median requires all previous values to be stored (although you can stream so that it's computed in only one pass), which would make it unusable in big data contexts.

@kasia-kobalczyk
Copy link
Collaborator Author

Streaming median can be efficiently calculated with two heaps: left heap with the largest element on top, right heap with the smallest element on top; the median is then just the average of the two top values (in case when n even) or one of the two top values (in case when n is odd).

But sure, this is an exact solution which requires O(n) memory. So for big data an approximate method should be used.

@THargreaves THargreaves modified the milestone: v0.1 Jan 13, 2022
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