Skip to content

auto-infer locations for predict_dte/pte/ldte/lpte (#68)#114

Open
okiner-3 wants to merge 1 commit into
mainfrom
auto-infer-locations
Open

auto-infer locations for predict_dte/pte/ldte/lpte (#68)#114
okiner-3 wants to merge 1 commit into
mainfrom
auto-infer-locations

Conversation

@okiner-3

Copy link
Copy Markdown
Collaborator

Summary

Closes #68. Make the locations argument optional in predict_dte, predict_pte, predict_ldte, and predict_lpte. When omitted, locations are generated automatically from the observed outcomes so users no longer need to write np.linspace(Y.min(), Y.max(), N) themselves.

Behavior

  • locations=None (default) → evenly-spaced locations spanning [Y.min(), Y.max()], with the bin count derived from np.histogram_bin_edges(outcomes, bins='auto') (combines Sturges and Freedman-Diaconis rules, scaling with data size and IQR).
  • For predict_pte / predict_lpte, the left endpoint is shifted just below outcomes.min() so that the smallest observation falls inside the first interval (loc[0], loc[1]].
  • locations=ndarray (existing behavior) → used as-is. Fully backward compatible.
  • The actual locations array used is stored on estimator.last_locations for plotting / downstream use.

Example

# Before
locations = np.linspace(Y.min(), Y.max(), 20)
dte, lo, hi = est.predict_dte(1, 0, locations)
plot(locations, dte, lo, hi, ...)

# After
dte, lo, hi = est.predict_dte(1, 0)
plot(est.last_locations, dte, lo, hi, ...)

Test plan

  • Added _infer_default_locations unit tests (tests/test_utils.py).
  • Added auto-locations tests for SimpleDistributionEstimator.predict_dte / predict_pte (tests/test_simple_estimator.py).
  • Added auto-locations tests for SimpleLocalDistributionEstimator.predict_ldte / predict_lpte (tests/test_local_estimators.py).
  • Existing 49 tests still pass; total 59 tests pass.

Make the locations argument optional in predict_dte, predict_pte,
predict_ldte, and predict_lpte. When omitted, locations are generated
automatically from the observed outcomes using np.linspace with a bin
count derived from np.histogram_bin_edges(outcomes, bins='auto'). For
the interval-based methods (PTE/LPTE), the left endpoint is shifted
just below outcomes.min() so the smallest observation falls inside the
first interval.

The actual locations array used is stored on estimator.last_locations
for plotting and downstream use.
@okiner-3 okiner-3 self-assigned this Jun 12, 2026
@okiner-3 okiner-3 requested a review from TomeHirata June 12, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto inference of locations

1 participant