-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Hi,
Thanks for your work writting the tool that calculates the sweights. However I think the user might not need the weights in an array but as a function. At the end the sWeights are just a 1D function of the mass. So what I think should happen is more like:
d_wgt = compute_sweights(model, data)
arr_wgt = d_wgt['nsig']
fun = Function(x=arr_mass, y=arr_wgt)
fun.save('swt_v1.json')that way, if you need those weights you do:
fun = Function.load('swt_v1.json')
#For one mass value
wgt=fun(5202)
# or if you need the whole array
arr_wgt = fun([2464, 4564, 4945])that way you would be able to keep around in disk many versions of the sweights (from different fitting models, for instance) and load them whenever you need them. I implemented a Function class in:
https://github.com/acampove/dmu/blob/main/src/dmu/stats/function.py
https://github.com/acampove/dmu/blob/main/tests/stats/test_function.py
feel free to pick up what you need from the code.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels