pyhs3.compiled.compile_nll¶
- pyhs3.compiled.compile_nll(log_prob, free, baked, initial, bounds, *, gradient=True, backend='c', fuse=False, mode=None, cache=None, batched=False, parameters_of_interest=(), data=None)[source]¶
Compile
-sum(log_prob)as a function of one vector offreescalars.This is the implementation behind
pyhs3.Model.compile_nll(); see that method for the user-facing description.- Parameters:
log_prob (
TensorVar) – Joint log-likelihood; summed over its (parameter-batch) axis.free (
Sequence[TensorVar]) – Scalar input variables to expose, in vector order.baked (
Mapping[TensorVar,Buffer|_SupportsArray[dtype[Any]] |_NestedSequence[_SupportsArray[dtype[Any]]] |complex|bytes|str|_NestedSequence[complex|bytes|str]]) – Remaining inputs (e.g. observed data) and the values baked in.initial (
Sequence[float]) – Starting value per free parameter.bounds (
Sequence[tuple[float,float]]) –(lower, upper)per free parameter.gradient (
bool) – Also compile the gradient with respect tofree.backend (
Literal['c','jax']) –"c"for PyTensor’s C linker,"jax"to transpile to JAX and compile with XLA.fuse (
bool) – Keep the elemwise-fusion rewrites in the default mode (seedefault_nll_mode()).mode (
Mode|str|None) – PyTensor mode;default_nll_mode(fuse=fuse)ifNone.cache (
bool|str|PathLike[str] |None) –Truefor the default cache directory, a path for a specific one,None/Falsefor no on-disk cache.batched (
bool) – Evaluate a(K, P)batch of parameter vectors per call (backend="jax"only); returns aBatchedCompiledNLL.parameters_of_interest (
Sequence[str]) – Names of the parameters of interest, exposed asCompiledNLL.parameters_of_interestwith theirCompiledNLL.poi_indices; names of variables not infreeare left out. They do not change the compiled function.data (
Mapping[str,tuple[TensorVar,Buffer|_SupportsArray[dtype[Any]] |_NestedSequence[_SupportsArray[dtype[Any]]] |complex|bytes|str|_NestedSequence[complex|bytes|str]]] |None) – Variables oflog_prob(e.g. the constants holding observed bin counts or global observables) to replace by per-call inputs, each with its default value, keyed by the name thedataargument ofCompiledNLL.value()uses. The compiled function takes them after the parameter vector, in this order.
- Returns:
The compiled likelihood.
- Return type: