Skip to content

Commit 582ce21

Browse files
committed
Better timeslices
Finally fixes #7 and produces a much nicer looking fit for large tree sequences, but leads to slightly worse performance for tiny tree sequences such as those tested in test_accuracy.py, because of #230. When we fix that, this PR should provide uniformly better performance, I hope
1 parent 957a08e commit 582ce21

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
- The default `min_branch_length` and `eps` have been set to 1e-8 rather than 1e-10, to avoid
1212
occasional issues with floating point error.
1313

14+
- A slight adjustement in the default timeslices used for the discrete-time method: see
15+
https://github.com/tskit-dev/tsdate/pull/233 for a rationale.
16+
1417
## [0.2.4] - 2025-09-18
1518

1619
- Add support for Python 3.13, minimum version is now 3.10.

tsdate/prior.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,10 @@ def create_timepoints(base_priors, n_points=21):
936936
# missing samples, otherwise we only have one set of priors anyway
937937
prior_params = base_priors.prior_with_max_total_tips()
938938
# Percentages - current day samples should be at time 0, so we omit this
939-
# We can't include the top end point, as this leads to NaNs
940-
percentiles = np.linspace(0, 1, n_points + 1)[1:-1]
939+
# We can't include 1 at the top end as it will be at infinite time
940+
# so we take the upper time point to be a fraction lower than 1 (as if we divided
941+
# the last timeslice into n_points evenly picked quantiles and removed the last one)
942+
percentiles = np.linspace(0, 1 - 1 / (n_points**2), n_points)[1:]
941943
# percentiles = np.append(percentiles, 0.999999)
942944
param_cols = np.where([f not in ("mean", "var") for f in PriorParams._fields])[0]
943945
"""

0 commit comments

Comments
 (0)