francescoalemanno / bayeshistogram.jl Goto Github PK
View Code? Open in Web Editor NEWpure Julia package for optimal histogram binning, based on piecewise constant model.
License: MIT License
pure Julia package for optimal histogram binning, based on piecewise constant model.
License: MIT License
Planned for next release
Still reading the paper and I'm wondering how does weights
work with this algorithm, for two reasons:
elaborate the point 2 a bit, often the raw data is >> RAM, the best I can do is to first make a really fine-binning histogram, then re-bin it
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
julia> BayesHistogram.bayesian_blocks(rand(1000); weights=randn(1000)).edges
ERROR: BoundsError: attempt to access 1001-element Vector{Float64} at index [[0, 1001]]
Stacktrace:
[1] throw_boundserror(A::Vector{Float64}, I::Tuple{Vector{Int64}})
@ Base ./abstractarray.jl:703
[2] checkbounds
@ ./abstractarray.jl:668 [inlined]
[3] _getindex
@ ./multidimensional.jl:874 [inlined]
[4] getindex
@ ./abstractarray.jl:1241 [inlined]
[5] bayesian_blocks(t::Vector{Float64}; weights::Vector{Float64}, prior::Pearson{Float64}, resolution::Float64, min_counts::Int64)
@ BayesHistogram ~/.julia/packages/BayesHistogram/V6yoj/src/BayesHistogram.jl:144
[6] top-level scope
@ REPL[20]:1
julia> using NPZ
julia> npzread("./data_gen.npz")
Dict{String, Vector{Float64}} with 2 entries:
"weights" => [1.03524, 1.59065, 1.92159, 1.7245, 1.25175, 1.1111, 1.0…
"data" => [-1.13384, 0.384319, 1.49655, -0.355382, -0.787534, -0.4…
julia> datas = npzread("./data_gen.npz");
julia> answers = npzread("./answers_bayesian_blocks.npz");
julia> bayesian_blocks(datas["data"]).edges
8-element Vector{Float64}:
-3.154662950679158
-2.126058692427544
-1.5407490071030014
-0.7146943329219142
0.6404466881064395
1.3817680464742417
2.1781371551736664
3.265843988558946
julia> answers["be1"]
9-element Vector{Float64}:
-3.154662950679158
-2.366746726914241
-1.8916975822891833
-1.2379204553303205
-0.7146943329219142
0.6404466881064395
1.3817680464742417
2.2181565018686125
3.265843988558946
to make the data
import numpy as np
np.random.seed(111)
data1 = np.random.normal(size=1000)
data2 = np.random.normal(2, 1, size=1000)
weights = np.random.uniform(1, 2, size=1000)
np.savez("data_gen.npz", data=data1, weights=weights)
here's the output:
data_gen.npz.txt
answers_bayesian_blocks.npz
In [22]: modeling.bayesian_blocks(np.ceil(np.random.randn(1000) * 100))
Out[22]:
array([-284. , -211. , -131.5, -90.5, 67.5, 131.5, 176.5, 259.5,
326. ])
(I will make a PR)
@JuliaRegistrator register
since for already binned data:
sum(w.^2) != sum(w2)
we should allow passing a weights2 argument.
@Moelf : wanna have a stab at it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.