Skip to content

Commit

Permalink
enh: use the autograd_params to not take a gradient with respect to l…
Browse files Browse the repository at this point in the history
…ambda
  • Loading branch information
jonas-eschle committed Nov 1, 2024
1 parent 2e8f2ee commit 10bba2e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ def __init__(
The default space is used for example in the sample method: if no
sampling limits are given, the default space is used.
If the observables are binned and the model is unbinned, the
model will be a binned model, by wrapping the model in a
:py:class:`~zfit.pdf.BinnedFromUnbinnedPDF`, equivalent to
calling :py:meth:`~zfit.pdf.BasePDF.to_binned`.
If the observables are binned and the model is unbinned, the
model will be a binned model, by wrapping the model in a
:py:class:`~zfit.pdf.BinnedFromUnbinnedPDF`, equivalent to
calling :py:meth:`~zfit.pdf.BasePDF.to_binned`.
The observables are not equal to the domain as it does not restrict or
truncate the model outside this range. |@docend:pdf.init.obs|
mu: Location parameter. Shifts the distribution left/right.
Expand All @@ -281,10 +291,13 @@ def __init__(
``ext_*`` methods and the ``counts`` (for binned PDFs). |@docend:pdf.init.extended|
norm: |@doc:pdf.init.norm| Normalization of the PDF.
By default, this is the same as the default space of the PDF. |@docend:pdf.init.norm|
name: |@doc:pdf.init.name| Human-readable name
name: |@doc:pdf.init.name| Name of the PDF.
Maybe has implications on the serialization and deserialization of the PDF.
For a human-readable name, use the label. |@docend:pdf.init.name|
label: |@doc:pdf.init.label| Human-readable name
or label of
the PDF for better identification. |@docend:pdf.init.name|
label: |@doc:pdf.init.label| Label of the PDF, if None is given, it will be the name. |@docend:pdf.init.label|
the PDF for a better description, to be used with plots etc.
Has no programmatical functional purpose as identification. |@docend:pdf.init.label|
"""
params = {
"mu": mu,
Expand All @@ -297,10 +310,20 @@ def __init__(
"alphar": alphar,
"nr": nr,
}
super().__init__(obs=obs, params=params, name=name, extended=extended, norm=norm, label=label)
autograd_params = set(params) - {"lambd"}
super().__init__(
obs=obs,
params=params,
name=name,
extended=extended,
norm=norm,
label=label,
autograd_params=autograd_params,
)

@zfit.supports()
def _unnormalized_pdf(self, x: tf.Tensor, params) -> tf.Tensor:
@zfit.supports(norm=False)
def _pdf(self, x: tf.Tensor, norm, params) -> tf.Tensor:
del norm
x0 = x[0]
mu = params["mu"]
sigma = params["sigma"]
Expand All @@ -311,5 +334,4 @@ def _unnormalized_pdf(self, x: tf.Tensor, params) -> tf.Tensor:
nl = params["nl"]
alphar = params["alphar"]
nr = params["nr"]

return hypatia2_func(x0, mu, sigma, lambd, zeta, beta, alphal, nl, alphar, nr)

0 comments on commit 10bba2e

Please sign in to comment.