Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Tsallis PDF #70

Merged
merged 11 commits into from
Apr 1, 2024
Merged
10 changes: 6 additions & 4 deletions zfit_physics/models/pdf_tsallis.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def tsallis_pdf_func(x, m, t, n):

Notes:
Based on code from `numba-stats <https://github.com/HDembinski/numba-stats/blob/main/src/numba_stats/tsallis.py>`_.
Formula from CMS, Eur. Phys. J. C (2012) 72:2164
"""
if run.executing_eagerly():
if n <= 2:
Expand All @@ -32,7 +33,7 @@ def tsallis_pdf_func(x, m, t, n):
tf.debugging.assert_greater(n, znp.asarray(2.0), message="n > 2 is required")

x = z.unstack_x(x)
mt = znp.sqrt(znp.square(m) + znp.square(x))
mt = znp.hypot(m, x)
ikrommyd marked this conversation as resolved.
Show resolved Hide resolved
nt = n * t
c = (n - 1) * (n - 2) / (nt * (nt + (n - 2) * m))
return c * x * znp.power(1 + (mt - m) / nt, -n)
Expand All @@ -53,6 +54,7 @@ def tsallis_cdf_func(x, m, t, n):

Notes:
Based on code from `numba-stats <https://github.com/HDembinski/numba-stats/blob/main/src/numba_stats/tsallis.py>`_.
Formula from CMS, Eur. Phys. J. C (2012) 72:2164
"""
if run.executing_eagerly():
if n <= 2:
Expand All @@ -62,7 +64,7 @@ def tsallis_cdf_func(x, m, t, n):
tf.debugging.assert_greater(n, znp.asarray(2.0), message="n > 2 is required")

x = z.unstack_x(x)
mt = znp.sqrt(m * m + znp.square(x))
mt = znp.hypot(m, x)
nt = n * t
return znp.power((mt - m) / nt + 1, 1 - n) * (m + mt - n * (mt + t)) / (m * (n - 2) + nt)

Expand Down Expand Up @@ -108,8 +110,8 @@ def __init__(
minimum bias particle collisions.


Formula for the PDF and CDF are based on code from
`numba-stats <https://github.com/HDembinski/numba-stats/blob/main/src/numba_stats/tsallis.py>`_
Based on code from `numba-stats <https://github.com/HDembinski/numba-stats/blob/main/src/numba_stats/tsallis.py>`_.
Formula from CMS, Eur. Phys. J. C (2012) 72:2164

Args:
m: Mass of the particle.
Expand Down
Loading