joshday / OnlineStats.jl

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

[speculative] `NullStat` #276

Closed adienes closed 6 months ago

adienes commented 6 months ago

I have some use cases where I might pass in any arbitrary OnlineStat type; occasionally I want this to be a no-op but not change the signature of the function

any receptiveness to adding a NullStat where fit!(::NullStat, x) simply does nothing?

just an idea

joshday commented 6 months ago

Seems a bit niche to add to the package, but it's pretty easy to do yourself:

import OnlineStatsBase: OnlineStat, _fit!, nobs, value
struct NullStat <: OnlineStat{Any} end 
value(::NullStat) = nothing 
nobs(::NullStat) = 0
_fit!(::NullStat, x) = nothing
julia> using OnlineStats

julia> fit!(NullStat(), randn(100))
NullStat: n=0 | value=nothing