From 748755a3b252fdbce80d8054d3b5c838b1b0318c Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Mon, 9 Jan 2023 00:06:32 +0000 Subject: [PATCH] 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 --- tsdate/prior.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tsdate/prior.py b/tsdate/prior.py index e445ef61..7cbf7168 100644 --- a/tsdate/prior.py +++ b/tsdate/prior.py @@ -888,8 +888,10 @@ def create_timepoints(base_priors, n_points=21): # missing samples, otherwise we only have one set of priors anyway prior_params = base_priors.prior_with_max_total_tips() # Percentages - current day samples should be at time 0, so we omit this - # We can't include the top end point, as this leads to NaNs - percentiles = np.linspace(0, 1, n_points + 1)[1:-1] + # We can't include 1 at the top end as it will be at infinite time + # so we take the upper time point to be a fraction lower than 1 (as if we divided + # the last timeslice into n_points evenly picked quantiles and removed the last one) + percentiles = np.linspace(0, 1 - 1 / (n_points**2), n_points)[1:] # percentiles = np.append(percentiles, 0.999999) param_cols = np.where([f not in ("mean", "var") for f in PriorParams._fields])[0] """