Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pymc/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -2825,6 +2825,13 @@ def logp(value, nu, sigma):
msg="sigma > 0, nu > 0",
)

def icdf(value, nu, sigma):
# Map half-t quantiles to full StudentT quantiles:
# F_half^{-1}(u) = F_t^{-1}((u + 1)/2; nu, mu=0, sigma)
res = icdf(StudentT.dist(nu, 0.0, sigma), (value + 1.0) / 2.0)
res = check_icdf_value(res, value)
return res


class ExGaussianRV(SymbolicRandomVariable):
name = "exgaussian"
Expand Down
7 changes: 7 additions & 0 deletions tests/distributions/test_continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,13 @@ def test_studentt_icdf(self):
lambda q, nu, mu, sigma: st.t.ppf(q, nu, mu, sigma),
)

def test_halfstudentt_icdf(self):
check_icdf(
pm.HalfStudentT,
{"nu": Rplusbig, "sigma": Rplusbig},
lambda q, nu, sigma: st.t.ppf(0.5 * (q + 1.0), nu, 0.0, sigma),
)

@pytest.mark.skipif(
condition=(pytensor.config.floatX == "float32"),
reason="Fails on float32 due to numerical issues",
Expand Down
Loading