FHist.ATLASTHEMEConstant

Example

with_theme(ATLASTHEME) do
    h1 = Hist1D(randn(10^4))
    hist(h1; label="atlas style histogram")
end
FHist.Hist1DMethod
Hist1D(array, edges::AbstractRange; overflow)
Hist1D(array, edges::AbstractVector; overflow)

Create a Hist1D with given bin edges and vlaues from array. Weight for each value is assumed to be 1.

FHist.Hist1DMethod
Hist1D(array, wgts::AbstractWeights, edges::AbstractRange; overflow)
Hist1D(array, wgts::AbstractWeights, edges::AbstractVector; overflow)

Create a Hist1D with given bin edges and vlaues from array. wgts should have the same size as array.

FHist.Hist1DMethod
Hist1D(A::AbstractVector{T}; nbins::Integer=_sturges(A), overflow) where T
Hist1D(A::AbstractVector{T}, wgts::AbstractWeights; nbins::Integer=_sturges(A), overflow) where T

Automatically determine number of bins based on Sturges algo.

FHist.Hist1DMethod
Hist1D(elT::Type{T}=Float64; bins, overflow) where {T}

Initialize an empty histogram with bin content typed as T and bin edges. To be used with push! or atomic_push!. Default overflow behavior (false) will exclude values that are outside of binedges.

FHist.Hist2DMethod
Hist2D(Tuple{<:iterable, <:iterable}, edges::NTuple{2,AbstractRange}; overflow)
Hist2D(Tuple{<:iterable, <:iterable}, edges::NTuple{2,AbstractVector}; overflow)

Create a Hist2D with given bin edges and values from a 2-tuple of arrays of x, y values. Weight for each value is assumed to be 1.

FHist.Hist2DMethod
Hist2D(tuple, wgts::AbstractWeights, edges::NTuple{2,AbstractRange}; overflow)
Hist2D(tuple, wgts::AbstractWeights, edges::NTuple{2,AbstractVector}; overflow)

Create a Hist2D with given bin edges and values from a 2-tuple of arrays of x, y values. wgts should have the same size as elements of tuple.

FHist.Hist2DMethod
Hist2D(XsYs::Tuple; nbins::NTuple{2,Integer}, overflow) where T
Hist2D(XsYs::Tuple, wgts::AbstractWeights; nbins::NTuple{2,Integer}, overflow) where T

Automatically determine number of bins based on Sturges algo.

FHist.Hist2DMethod
Hist2D(elT::Type{T}=Float64; binedges, overflow) where {T}

Initialize an empty histogram with bin content typed as T and bin edges. To be used with push! or atomic_push!. Default overflow behavior (false) will exclude values that are outside of binedges.

FHist.Hist3DMethod
Hist3D(tuple, wgts::AbstractWeights, edges::NTuple{3,AbstractRange}; overflow)
Hist3D(tuple, wgts::AbstractWeights, edges::NTuple{3,AbstractVector}; overflow)

Create a Hist3D with given bin edges and values from a 2-tuple of arrays of x, y values. wgts should have the same size as elements of tuple.

FHist.Hist3DMethod
Hist3D(tuple, edges::NTuple{3,AbstractRange}; overflow)
Hist3D(tuple, edges::NTuple{3,AbstractVector}; overflow)

Create a Hist3D with given bin edges and values from a 2-tuple of arrays of x, y values. Weight for each value is assumed to be 1.

FHist.Hist3DMethod
Hist3D(A::AbstractVector{T}; nbins::NTuple{3,Integer}, overflow) where T
Hist3D(A::AbstractVector{T}, wgts::AbstractWeights; nbins::NTuple{3,Integer}, overflow) where T

Automatically determine number of bins based on Sturges algo.

FHist.Hist3DMethod
Hist3D(elT::Type{T}=Float64; binedges, overflow) where {T}

Initialize an empty histogram with bin content typed as T and bin edges. To be used with push! or atomic_push!. Default overflow behavior (false) will exclude values that are outside of binedges.

Base.empty!Method
empty!(h::Hist1D)

Resets a histogram's bin counts and sumw2.

Base.empty!Method
empty!(h::Hist2D)

Resets a histogram's bin counts and sumw2.

Base.empty!Method
empty!(h::Hist3D)

Resets a histogram's bin counts and sumw2.

FHist._factorMethod
function _factor(n::Integer)

Helper function to calculate the prime factors of a given integer.

FHist.atomic_push!Method
push!(h::Hist1D, val::Real, wgt::Real=1)
atomic_push!(h::Hist1D, val::Real, wgt::Real=1)

Adding one value at a time into histogram. sumw2 (sum of weights^2) accumulates wgt^2 with a default weight of 1. atomic_push! is a slower version of push! that is thread-safe.

N.B. To append multiple values at once, use broadcasting via push!.(h, [-3.0, -2.9, -2.8]) or push!.(h, [-3.0, -2.9, -2.8], 2.0)

FHist.atomic_push!Method
push!(h::Hist2D, valx::Real, valy::Real, wgt::Real=1)
atomic_push!(h::Hist2D, valx::Real, valy::Real, wgt::Real=1)

Adding one value at a time into histogram. sumw2 (sum of weights^2) accumulates wgt^2 with a default weight of 1. atomic_push! is a slower version of push! that is thread-safe.

FHist.atomic_push!Method
push!(h::Hist3D, valx::Real, valy::Real, wgt::Real=1)
atomic_push!(h::Hist3D, valx::Real, valy::Real, wgt::Real=1)

Adding one value at a time into histogram. sumw2 (sum of weights^2) accumulates wgt^2 with a default weight of 1. atomic_push! is a slower version of push! that is thread-safe.

FHist.bayes_rebin_edgesMethod
bayes_rebin_edges(h::Hist1D; prior=BayesHistogram.Geometric(0.995))

Find optimal bin edges for a histogram using Bayesian rebinning algorithm. This function only find edges, it doesn't return a new histogram.

For possible priors, see BayesHistogram.jl.

FHist.bincentersMethod
bincenters(h::Hist1D)

Get the bin centers of a histogram.

FHist.bincentersMethod
bincenters(h::Hist2D)

Get a 2-tuple of the bin centers of a histogram.

FHist.bincentersMethod
bincenters(h::Hist3D)

Get a 2-tuple of the bin centers of a histogram.

FHist.bincountsMethod
bincounts(h::Hist1D)

Get the bin counts of a histogram.

FHist.bincountsMethod
bincounts(h::Hist2D)

Get the bin counts of a histogram.

FHist.bincountsMethod
bincounts(h::Hist3D)

Get the bin counts of a histogram.

FHist.binedgesMethod
binedges(h::Hist1D)

Get the bin edges of a histogram.

FHist.binedgesMethod
binedges(h::Hist2D)

Get a 2-tuple of the bin edges of a histogram.

FHist.binedgesMethod
binedges(h::Hist3D)

Get a 3-tuple of the bin edges of a histogram.

FHist.binerrorsMethod
binerrors(f::T, h::Hist1D) where T<:Function = f.(h.sumw2)
binerrors(h::Hist1D) = binerrors(sqrt, h)

Calculate the bin errors from sumw2 with a Gaussian default.

FHist.binerrorsMethod
binerrors(f::T, h::Hist2D) where T<:Function = f.(h.sumw2)
binerrors(h::Hist2D) = binerrors(sqrt, h)

Calculate the bin errors from sumw2 with a Gaussian default.

FHist.binerrorsMethod
binerrors(f::T, h::Hist3D) where T<:Function = f.(h.sumw2)
binerrors(h::Hist3D) = binerrors(sqrt, h)

Calculate the bin errors from sumw2 with a Gaussian default.

FHist.cumulativeMethod
cumulative(h::Hist1D; forward=true)

Create a cumulative histogram. If forward, start summing from the left.

FHist.hists_to_barsMethod
hists_to_bars(hist1ds)

Given a vector of Hist1D, return edges (xs), heights (ys), and grps (for grouping) that is useful for plotting stacked histogram.

FHist.integralMethod
integral(h::Hist1D; width=false)

Get the integral a histogram; width means multiply each bincount by their bin width when calculating the integral.

Warning

Be aware of the approximation you make when using width=true with histogram with overflow bins, the overflow bins (i.e. the left/right most bins) width will be taken "as is".

FHist.integralMethod
integral(h::Hist2D)

Get the integral a histogram.

FHist.integralMethod
integral(h::Hist3D)

Get the integral a histogram.

FHist.lookupMethod
lookup(h::Hist1D, x)

For given x-axis value x, find the corresponding bin and return the bin content. If a value is out of the histogram range, return missing.

FHist.lookupMethod
function lookup(h::Hist2D, x, y)

For given x-axis and y-axis value x, y, find the corresponding bin and return the bin content. If a value is out of the histogram range, return missing.

FHist.lookupMethod
function lookup(h::Hist3D, x, y)

For given x/y/z-axis value x, y, z, find the corresponding bin and return the bin content. If a value is out of the histogram range, return missing.

FHist.nbinsMethod
nbins(h::Hist1D)

Get the number of bins of a histogram.

FHist.nbinsMethod
nbins(h::Hist2D)

Get a 2-tuple of the number of x and y bins of a histogram.

FHist.nbinsMethod
nbins(h::Hist3D)

Get a 3-tuple of the number of x and y bins of a histogram.

FHist.profileFunction
profile(h::Hist2D, axis::Symbol=:x)
profile(axis::Symbol=:x) = h::Hist2D -> profile(h, axis)

Returns the axis-profile of the 2D histogram by calculating the weighted mean over the other axis. profile(h, :x) will return a Hist1D with the y-axis edges of h.

FHist.projectFunction
project(h::Hist2D, axis::Symbol=:x)
project(axis::Symbol=:x) = h::Hist2D -> project(h, axis)

Computes the :x (:y) axis projection of the 2D histogram by summing over the y (x) axis. Returns a Hist1D.

FHist.projectFunction
project(h::Hist3D, axis::Symbol=:x)
project(axis::Symbol=:x) = h::Hist3D -> project(h, axis)

Computes the :x/:y/:z axis projection of the 3D histogram by summing over the specified axis. Returns a Hist2D.

FHist.rebinFunction
rebin(h::Hist1D, n::Int=1)
rebin(n::Int) = h::Hist1D -> rebin(h, n)

Merges n consecutive bins into one. The returned histogram will have nbins(h)/n bins.

FHist.rebinFunction
rebin(h::Hist2D, nx::Int=1, ny::Int=nx)
rebin(nx::Int, ny::Int) = h::Hist2D -> rebin(h, nx, ny)

Merges nx (ny) consecutive bins into one along the x (y) axis by summing.

FHist.restrictFunction
restrict(h::Hist2D, xlow=-Inf, xhigh=Inf, ylow=-Inf, yhigh=Inf)
restrict(xlow=-Inf, xhigh=Inf, ylow=-Inf, yhigh=Inf) = h::Hist2D -> restrict(h, xlow, xhigh, ylow, yhigh)

Returns a new histogram with a restricted x-axis. restrict(h, 0, 3) (or h |> restrict(0, 3)) will return a slice of h where the bin centers are in [0, 3] (inclusive).

FHist.restrictFunction
restrict(h::Hist1D, low=-Inf, high=Inf)
restrict(low=-Inf, high=Inf) = h::Hist1D -> restrict(h, low, high)

Returns a new histogram with a restricted x-axis. restrict(h, 0, 3) (or h |> restrict(0, 3)) will return a slice of h where the bin centers are in [0, 3] (inclusive).

FHist.sampleMethod
sample(h::Hist1D, n::Int=1)

Sample a histogram's with weights equal to bin count, n times. The sampled values are the bins' lower edges.

FHist.significanceMethod
significance(signal, bkg) -> `(significance, error_on_significance)`

Calculate the significance of signal vs. bkg histograms, this function uses a more accurate algorithm than the naive S / sqrt(B)

Ref: https://cds.cern.ch/record/2736148/files/ATL-PHYS-PUB-2020-025.pdf

Example:

h1 = Hist1D(rand(1000), [0, 0.5])
h2 = Hist1D(rand(10000), [0, 0.5]);

julia> s1 = significance(h1,h2)
(6.738690967342175, 0.3042424717261312)
FHist.valid_rebin_valuesMethod
valid_rebin_values(h::Union{Hist1D, Hist2D, Hist3D})

Calculates the legal values for rebinning, essentially the prime factors of the number of bins. For a 1D histogram, a Set of numbers is return, for higher dimensional histograms a Vector{Set} for each dimension.

LinearAlgebra.normalizeMethod
normalize(h::Hist1D; width=true)

Create a normalized histogram via division by integral(h), when width==true, the resultant histogram has area under the curve equals 1.

Warning

Implicit approximation is made when using width=true with histograms that have overflow bins: the overflow data lives inthe left/right most bins and the bin width is taken "as is".

Statistics.meanMethod
Statistics.mean(h)
Statistics.std(h)
Statistics.median(h)
Statistics.quantile(h::Hist1D, p)

Compute statistical quantities based on the bin centers weighted by the bin counts.

When the histogram is Hist2D, return tuple instead, e.g (mean(project(h, :x)), mean(project(h, :y))) etc.