spey.math.value_and_grad#
- spey.math.value_and_grad(statistical_model: StatisticalModel, expected: ExpectationType = observed, data: List[float] | None = None) Callable[[ndarray], Tuple[ndarray, ndarray]] [source]#
Retreive function to compute negative log-likelihood and its gradient.
Added in version 0.1.6.
- Parameters:
statistical_model (StatisticalModel) – statistical model to be used.
expected (ExpectationType) –
Sets which values the fitting algorithm should focus and p-values to be computed.
observed
: Computes the p-values with via post-fit prescriotion which means that the experimental data will be assumed to be the truth (default).aposteriori
: Computes the expected p-values with via post-fit prescriotion which means that the experimental data will be assumed to be the truth.apriori
: Computes the expected p-values with via pre-fit prescription which means that the SM will be assumed to be the truth.
data (
List[float]
, defaultNone
) – input data that to fit. If None observed data will be used.
- Returns:
negative log-likelihood and its gradient with respect to nuisance parameters
- Return type:
Callable[[np.ndarray], Tuple[np.ndarray, np.ndarray]]