I launch the app and start retrieving some value from a sensor every 50 milliseconds
, I get some float value from [-1;1] range. How would I calculate the median value of all values I got from sensor since the launch of the app without storing them into any vector/array at all?
I understand that I can put values into a sorted collection and find the middle element or the sum of two middle elements divided by 2
. I also checked std::nth_element()
which doesn't even require sorting, however, I would want to avoid storing these numbers in a heap, stack or hard drive. The app can keep working for hours so the amount of number accumulated by the sensor will be massive.
Any ideas are appreciated.