custom
- class BaseCustomModel(amp, w_bkg=1.0, resolution_size=1, extended=False, **kwargs)[source]
Bases:
Model
- nll(data, mcdata, weight: Tensor = 1.0, batch=None, bg=None, mc_weight=1.0)[source]
Calculate NLL.
\[-\ln L = -\sum_{x_i \in data } w_i \ln f(x_i;\theta_k) + (\sum w_j ) \ln \sum_{x_i \in mc } f(x_i;\theta_k)\]- Parameters:
data – Data array
mcdata – MCdata array
weight – Weight of data???
batch – The length of array to calculate as a vector at a time. How to fold the data array may depend on the GPU computability.
bg – Background data array. It can be set to
None
if there is no such thing.
- Returns:
Real number. The value of NLL.
- nll_grad_batch(data, mcdata, weight, mc_weight)[source]
batch version of
self.nll_grad()
\[- \frac{\partial \ln L}{\partial \theta_k } = -\sum_{x_i \in data } w_i \frac{\partial}{\partial \theta_k} \ln f(x_i;\theta_k) + (\sum w_j ) \left( \frac{ \partial }{\partial \theta_k} \sum_{x_i \in mc} f(x_i;\theta_k) \right) \frac{1}{ \sum_{x_i \in mc} f(x_i;\theta_k) }\]- Parameters:
data
mcdata
weight
mc_weight
- Returns:
- nll_grad_hessian(data, mcdata, weight=1.0, batch=24000, bg=None, mc_weight=1.0)[source]
The parameters are the same with
self.nll()
, but it will return Hessian as well.- Return NLL:
Real number. The value of NLL.
- Return gradients:
List of real numbers. The gradients for each variable.
- Return Hessian:
2-D Array of real numbers. The Hessian matrix of the variables.
- class SimpleCFitModel(amp, w_bkg=1.0, resolution_size=1, extended=False, **kwargs)[source]
Bases:
BaseCustomModel
- required_params = ['bg_frac']
- class SimpleChi2Model(amp, w_bkg=1.0, resolution_size=1, extended=False, **kwargs)[source]
Bases:
BaseCustomModel
fit amp = weight directly. Required set extended = True.
- class SimpleClipNllModel(amp, w_bkg=1.0, resolution_size=1, extended=False, **kwargs)[source]
Bases:
SimpleNllModel
- class SimpleNllFracModel(amp, w_bkg=1.0, resolution_size=1, extended=False, **kwargs)[source]
Bases:
BaseCustomModel
- required_params = ['constr_frac', 'bg_frac']