Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Co-authored-by: Jonas Eschle <[email protected]>
  • Loading branch information
ikrommyd and jonas-eschle authored Mar 19, 2024
1 parent 1b99062 commit fac39dc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions zfit_physics/models/pdf_cruijff.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ def cruijff_pdf_func(x, mu, sigmal, alphal, sigmar, alphar):
"""
cond = znp.less(x, mu)

func = znp.where(
cond,
znp.exp(-0.5 * znp.square((x - mu) / sigmal) / (1 + alphal * znp.square((x - mu) / sigmal))),
znp.exp(-0.5 * znp.square((x - mu) / sigmar) / (1 + alphar * znp.square((x - mu) / sigmar))),
)
return func
# compute only once (in graph this _may_ be optimized anyways, but surely not in eager)
xminmu = (x - mu)
tleft = znp.square(xminmu / sigmal)
tright = znp.square(xminmu / sigmar)
exponent = znp.where(
cond,
tleft / (1 + alphal * tleft),
tright / (1 + alphar * tright),
)
value = znp.exp(-0.5 * exponent)
return value


class Cruijff(zfit.pdf.BasePDF):
Expand Down

0 comments on commit fac39dc

Please sign in to comment.