OrderedLogistic loses precision in interior-category tail log probabilities

Open
#8,655 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@saifmodan2006 is already working on this.

Since Nov 21, 2026.

  • #8657 by @saifmodan2006 — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
54/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by locating the OrderedLogistic log-probability implementation and its tests; the issue does not name their paths. Reproduce the supplied middle-category tail case and compare it with the stable log-space expression in the body. Done when interior-category log probabilities remain accurate in both tails and gradients remain finite where representable.

Written by the indexing model from the issue text.

Description

OrderedLogistic subtracts nearly equal cumulative probabilities for interior categories. On posteriordb bones_model the Stan-minus-PyMC A/B delta residual is 6.8568890583264874e-6 (tolerance 1.1033592634095134e-6); an independent log-space evaluation of the same likelihood reduces it to about 2.3e-13. Recorded points.

Small tail case from the data (middle category, zero-based index 1):

import numpy as np
import pymc as pm
from scipy.special import log_expit
eta = 8.1123 * -5
cuts = 8.1123 * np.array([0.3887, 1.0153])
print(pm.logp(pm.OrderedLogistic.dist(eta=eta, cutpoints=cuts), 1).eval())
lo, hi = cuts - eta
print(log_expit(hi) + log_expit(-lo) + np.log(-np.expm1(lo-hi)))

The reference log probability is finite even when both float64 CDFs round to one. Prob need to evaluate interior category log probabilities stably in both tails, retaining finite gradients where representable.

PyMC 6.4.0, PyTensor 3.3.7

Dominant language
Python
Stars
9.9k
Forks
2.4k
Avg merge
4d 10h
Merged PRs (30d)
12

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pymc-devs/pymc

All issues in pymc-devs/pymc

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.