Skip to content

Instantly share code, notes, and snippets.

View Mitchell-D's full-sized avatar

Mitchell Dodson Mitchell-D

  • University of Alabama in Huntsville Earth System Science Center
  • Huntsville, Alabama
View GitHub Profile
@davidbau
davidbau / runningstats.py
Last active December 20, 2025 22:24
Running stats objects for pytorch: mean, variance, covariance, second-moment, quantiles, topk, and combinations.
'''
To use a runningstats object,
1. Create the the desired stat object, e.g., `m = Mean()`
2. Feed it batches via the add method, e.g., `m.add(batch)`
3. Repeat step 2 any number of times.
4. Read out the statistic of interest, e.g., `m.mean()`
Built-in runningstats objects include: