binneddistributionfit.jl
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.6%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: Moelf
- License: mit
- Language: Julia
- Default Branch: main
- Homepage: https://moelf.github.io/BinnedDistributionFit.jl/
- Size: 3.68 MB
Statistics
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
BinnedDistributionFit
[Work In Progress]
Everything is subject to change, including type names and type hierarchy.
The Scope of this Package
We try to cover a core set of usages common in HEP, namely, fitting one or multiple distributions to binned data, using Chi2 or Likelihood objective.
Conceptually, given user defined function ("shape"), we can treat it as if it's a PDF by numerically normalizing it at every evaluating point. We then package that with a user defined histogram using the FHist package which can be used with an optimization or plotting package.
Quick Start
The following code provides a framework for optimizing a single function with any number of parameters. The guess must be relatively close to the real parameters. ```julia using BinnedDistributionFit, FHist, Optimization, ForwardDiff, ComponentArrays
function fitpdfto_hist(hist::Hist1D, pdf, guess::Vector) support = extrema(binedges(hist))
NLL = LikelihoodSpec(ExtendPdf(pdf, support), hist)
opt_f = OptimizationFunction(NLL, AutoForwardDiff())
opt_p = OptimizationProblem(opt_f, ComponentArray(norms = integral(hist), p1 = guess))
sol = solve(opt_p, Optimization.LBFGS())
return sol.u
end
Example
hist = Hist1D(; binedges=1:2:21, bincounts=[1:4; 1; 6:10]) pdf_input(x, ps) = ps[1]*x + ps[2] guess = [5, 5]
fitpdftohist(hist, pdfinput, guess)
output
ComponentVector{Float64}(norms = 51.0, p1 = [6.975319732308675, -0.8718290560996027]) ```
Math for One PDF fitting to Data: (i.e. ExtendPdf)
For main.py and main.jl (just the ExtendPdf)
if you change the observed bincounts from [2.0, 4.0] to [4.0, 8.0], the NLL becomes 1.3655798792934464
If on top of that, you also change p0 from 2.0 to 4.0, you get NLL -4.952186287425897
Math for sum of two PDFs fitting to data: (i.e. SUM:: in RooFit)
Owner
- Name: Jerry Ling
- Login: Moelf
- Kind: user
- Location: Cambridge, MA
- Website: blog.jling.dev
- Repositories: 195
- Profile: https://github.com/Moelf
HEP-ex PhD student @ Harvard LPPC; @JuliaHEP
Citation (CITATION.cff)
# Go to https://citation-file-format.github.io/cff-initializer-javascript/#/ to finish this
cff-version: 1.2.0
title: BinnedDistributionFit.jl
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Moelf
email: proton@jling.dev
GitHub Events
Total
- Watch event: 2
- Delete event: 4
- Issue comment event: 7
- Push event: 80
- Pull request review comment event: 3
- Pull request review event: 5
- Pull request event: 13
- Fork event: 2
- Create event: 11
Last Year
- Watch event: 2
- Delete event: 4
- Issue comment event: 7
- Push event: 80
- Pull request review comment event: 3
- Pull request review event: 5
- Pull request event: 13
- Fork event: 2
- Create event: 11
Dependencies
- actions/checkout v4 composite
- julia-actions/cache v2 composite
- julia-actions/julia-buildpkg v1 composite
- julia-actions/julia-runtest v1 composite
- julia-actions/setup-julia v2 composite
- JuliaRegistries/TagBot v1 composite
- actions/checkout v4 composite
- julia-actions/cache v2 composite
- julia-actions/setup-julia v2 composite
- actions/checkout v4 composite
- codecov/codecov-action v4 composite
- julia-actions/cache v2 composite
- julia-actions/julia-buildpkg v1 composite
- julia-actions/julia-processcoverage v1 composite
- julia-actions/julia-runtest v1 composite
- julia-actions/setup-julia v2 composite