joshday / OnlineStats.jl

⚡ Single-pass algorithms for statistics
https://joshday.github.io/OnlineStats.jl/latest/
MIT License
831 stars 62 forks source link

reset or clear a stats #203

Open yakir12 opened 4 years ago

yakir12 commented 4 years ago

Say I create a vector of Means. After using that structure, if I want to use it again, I'd need to reset its values first. Right now I need to recreate that structure again. This might be useful only in cases where the structure is really complicated/large.

joshday commented 4 years ago

I've thought about having Base.empty! methods that reset the state. I'm hesitant to add empty! as a required method to the OnlineStatsBase interface, but it would be nice to have those methods around.

torfjelde commented 3 years ago

Just adding my voice to the choir: it would be pretty nice to have empty! for OnlineStat:)

ericphanson commented 2 years ago

+1 for this. I'd like to use OnlineStats with Distributed.jl by having local stat objects on each processor, and then periodically merge! them onto stat objects on the driver. Then I'd like to empty the local objects to continue to accumulate stats on each processor. (For https://github.com/ericphanson/TrackingTimers.jl/issues/14). I think this would be much nicer with an empty! method.

joshday commented 2 years ago

Base.empty!(::OnlineStat) is an error, but I've added it as an optional part of the interface (via the OnlineStatsBase README).

If anyone wants to knock out a few methods, PRs welcome.