Skip to content

Function capability for splot tool #165

@acampove

Description

@acampove

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions