Comments (4)
mostly i figure if the histogram knows its widths i shouldn't have to type it
if useful you might crossreference other histograms in the julia ecosystem:
https://github.com/mitmath/18338/blob/master/JuliaNotebooks/0.0%20Histogramming.ipynb
see the word normalize
used in different ways
from fhist.jl.
we model after this function:
https://root.cern.ch/doc/master/classTH1.html#aaf053a4b487c46b9e20c0bf534b34012
if option "width" is specified, the integral is the sum of the bin contents multiplied by the bin width in x.
maybe the answer is to specifically fix normalize
? or we could add a ; width=false
to integral() function and use that in normalize
from fhist.jl.
we actually use StatsBase
under the hood haha, but yeah, HEP is weird.
There's not enough bandwidth in the community rn but one day I wish we could have a separate histogram package and StatsBase use that one, and we can sort out different "properties" of histograms by using the type system (where now there's like isdensity
https://github.com/JuliaStats/StatsBase.jl/blob/39d0433f5044f8cafaa902cf31b3f83979585657/src/hist.jl#L190 field ad-hoc)
from fhist.jl.
ROOT's behavior when having variable bin width:
In [10]: ROOT.TH1D("test", "test", 3, array.array("d", [0, 1, 2, 4]))
Out[10]: <cppyy.gbl.TH1D object at 0x5de8700>
In [11]: t.Fill(0.5, 0.5)
Out[11]: 1
In [12]: t.Fill(0.5, 0.5)
Out[12]: 1
In [14]: t
Out[14]: <cppyy.gbl.TH1D object at 0x605e730>
In [15]: t.Integral()
Out[15]: 1.0
In [16]: t.Fill(2.5, 0.5)
Out[16]: 3
In [17]: t.Integral()
Out[17]: 1.5
In [18]: t.Integral("width")
Out[18]: 2.0
as for different "normalize()", see discussion: https://root-forum.cern.ch/t/different-ways-of-normalizing-histograms/15582
Method 4
In [28]: t.Scale(1. / t.Integral())
In [29]: t.GetBinContent(3)
Out[29]: 0.3333333333333333
Method 6
# re-make t
In [30]: t = ROOT.TH1D("test", "test", 3, array.array("d", [0, 1, 2, 4]))
TROOT::Append:0: RuntimeWarning: Replacing existing TH1: test (Potential memory leak).
In [31]: t.Fill(0.5, 0.5)
Out[31]: 1
In [32]: t.Fill(0.5, 0.5)
Out[32]: 1
In [33]: t.Fill(2.5, 0.5)
Out[33]: 3
In [34]: t.Scale(1. / t.Integral("width"))
In [35]: t.GetBinContent(3)
Out[35]: 0.25
In [36]: t.Integral()
Out[36]: 0.75
In [37]: t.Integral("width")
Out[37]: 1.0
from fhist.jl.
Related Issues (20)
- Number of entries not properly 'merged' HOT 8
- cumulative reverse order HOT 3
- Should there be a function return sumw2? HOT 4
- Can this be Real? HOT 7
- Weird behavior HOT 1
- Naming of push/unsafe_push HOT 1
- unsafe_push when only 1 thread HOT 1
- implement Hist3D
- High precision bin edges make overfull display HOT 3
- Nonuniform weights? HOT 5
- FHist type-parameter (of eltype) is also used for the weights HOT 7
- Statbox not working on a normalized histogram
- Normalize broken ? HOT 1
- normalize, width = true HOT 5
- Is normal that memory allocations happens when filling? HOT 16
- Problem with recipes HOT 15
- [RFC] `v0.11` breaking change to main API HOT 10
- FHistCairoMakieExt not found HOT 3
- Pushing `-Inf` and `Inf` HOT 4
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 fhist.jl.