Skip to content

Commit bb7b048

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 c9db1d9 commit bb7b048

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tsdate/prior.py

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

0 commit comments

Comments
 (0)