-
-
Save Moelf/ab2f10ce45873bb91eaec60ace8388c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Turing, LiteHF, Optim | |
| ###### Dummy data ###### | |
| const v_data = [34,22,13,11] # observed data | |
| const v_sig = [2,3,4,5] # signal | |
| const v_bg = [30,19,9,4] # BKG | |
| const variations = [1,2,3,3] | |
| ###### Background and Signal modifier definitions ###### | |
| const bkgmodis =[ | |
| Histosys(v_bg .+ variations, v_bg .- variations), | |
| Normsys(1.1, 0.9) | |
| ] | |
| const bkgexp = ExpCounts(v_bg, bkgmodis) | |
| const sigmodis = [Normfactor()]; | |
| const sigexp = ExpCounts(v_sig, sigmodis); | |
| ###### Expected counts as a function of μ and θs | |
| function expected_bincounts2(μ, θs) | |
| sigexp(μ) + bkgexp(θs) | |
| end | |
| ###### Turing.jl models | |
| @model function binned_b(bincounts) | |
| μ ~ Uniform(0, 6) | |
| θs ~ filldist(Normal(), 2) | |
| expected = expected_bincounts2(μ, θs) | |
| @. bincounts ~ Poisson(expected) | |
| end | |
| ###### Feed observed data to model to construct a posterior/likelihood object | |
| const mymodel = binned_b(v_data); | |
| ###### Inference | |
| chain_map = optimize(mymodel, MAP(), [1,1,1]) | |
| display(chain_map) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment