Track: Real time mean computation tool? #56

Closed
opened 2024-04-23 04:20:09 +02:00 by Benjamin_Loison · 1 comment
See [Benjamin-Loison/cpython/issues/19](https://github.com/Benjamin-Loison/cpython/issues/19).
Benjamin_Loison added the
enhancement
low priority
quick
labels 2024-04-23 04:20:09 +02:00
Author
Owner

class iterativeMean:
mean = None
numberOfElementsInMean = 0
def add(self, element):
if self.mean is None:
self.mean = element
else:
self.mean = ((self.mean * self.numberOfElementsInMean) + element) / (self.numberOfElementsInMean + 1)
self.numberOfElementsInMean += 1

https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/src/commit/ec4657eda81f0fa448cadc3e09b10437d499da85/datasets/raise/utils.py#L87-L96
Sign in to join this conversation.
No description provided.