Comments (4)
A few things:
1) Thanks for the report! I was able to make a simpler example:
julia> typeof(Group([Mean() for _ in 1:1375]...))
Group{NTuple{1375, Mean{Float64, EqualWeight}}, Union{NTuple{1375, Number}, NamedTuple{names, R} where R<:NTuple{1375, Number}, AbstractVector{<:Number}} where names}
julia> typeof(Group([Mean() for _ in 1:1376]...))
ERROR: StackOverflowError:
Stacktrace:
[1] promote_type(::Type, ::Type, ::Type, ::Type, ::Vararg{Type}) (repeats 1368 times)
@ Base ./promotion.jl:293
[2] Group(stats::NTuple{1376, Mean{Float64, EqualWeight}})
@ OnlineStatsBase ~/.julia/dev/OnlineStatsBase/src/stats.jl:368
[3] Group(::Mean{Float64, EqualWeight}, ::Vararg{Mean{Float64, EqualWeight}})
@ OnlineStatsBase ~/.julia/dev/OnlineStatsBase/src/stats.jl:372
I am at a loss as to why 1375 would be different than 1376. However, there is a one-line fix in OnlineStatsBase that I'll add:
# don't do this. See below
julia> typeof(Group([Mean() for _ in 1:999999]...))
Group{NTuple{999999, Mean{Float64, EqualWeight}}, Union{Tuple{Number}, NamedTuple{names, R} where R<:Tuple{Number}, AbstractVector{<:Number}} where names}
2) For large numbers of stats in a Group
, use a Vector
:
julia> typeof(Group([Mean() for _ in 1:999999]))
Group{Vector{Mean{Float64, EqualWeight}}, Union{Tuple{Number}, NamedTuple{names, R} where R<:Tuple{Number}, AbstractVector{<:Number}} where names}
I'll have to do some benchmarking. There may be no benefit for using tuples even for a smaller number of stats.
3) If you already have a Variance
, don't add in a Mean
A Variance
needs to calculate the mean internally, so you're adding unnecessary compute by including a Mean
as well. You can do:
o = fit!(Variance(), randn(100))
mean(o)
from onlinestats.jl.
Eh, I lied. My "fix" broke other stuff. This may be some internal Julia limitation on tuple sizes. I'll look into it.
from onlinestats.jl.
Figured it out. This is the culprit, which lives in Base:
promote_type(T, S, U, V...) = (@inline; promote_type(T, promote_type(S, U, V...)))
For a large number of arguments, e.g. promote_type(many_things...)
, this method is called over and over so we hit a stack overflow. Fortunately, changing some OnlineStatsBase code from promote_type(types...)
to reduce(promote_type, types)
fixes everything.
Re: Vectors vs. Tuples as the Group
container: Tuples are faster for a small number of items.
from onlinestats.jl.
new OnlineStatsBase release is pending.
from onlinestats.jl.
Related Issues (20)
- Possible type instability in `OnlineStatsBase.jl` HOT 1
- Group with 3 Stats not working for multi-observations? HOT 3
- Julia VS Code extension reports "Possible method call error" for `fit!` HOT 3
- _fit! on AutoCov is not type stable HOT 1
- Extract field of an observation before feeding an OnlineStats - ValueExtractor wrapper HOT 2
- Feature Request: OnlineStat Chaining HOT 1
- Using StatLag without depending on OnlineStats (just OnlineStatsBase) HOT 4
- ExtremeValues doesn't work HOT 2
- Odd interaction of `Group` with broadcast HOT 2
- [speculative] `NullStat` HOT 1
- Plot of GroupBy of HeatMap fails HOT 1
- when fit!-ing a Group to a NamedTuple, the names are ignored HOT 2
- Documentation Request: List which Monoids support merge HOT 1
- Feature Request: PCA wrapper around CovMatrix which also supports transform methods
- Pretty printing is unpretty inside DataFrame HOT 5
- Support `keys` and `values` on `GroupBy` HOT 1
- Bug: Y-Marginals for heatmap are wrong HOT 1
- Allow counts argument in `fit!` HOT 5
- Suggestions for OnlineStats v2 HOT 1
- Standard Deviation - StdDev HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onlinestats.jl.