birdepy / birdepy_project

BirDePy is a Python package for working with continuous time birth-and-death processes.
https://birdepy.github.io
GNU General Public License v3.0
7 stars 1 forks source link

Can't change the percentiles using forecast #62

Open krishynan opened 6 months ago

krishynan commented 6 months ago

I've tried several ways to change the percentiles using the forecast function to no avail. I'm running it on Google Colab.

Easily reproducible steps:

1- Use the example code provided in https://birdepy.github.io/api_forecast.html and add the percentiles and labels options

!pip install birdepy
import birdepy as bd
t_data = list(range(101))
p_data = bd.simulate.discrete([0.75, 0.25, 0.02, 1], 'Ricker', 10, t_data,
                              survival=True, seed=2021)
est = bd.estimate(t_data, p_data, [0.5, 0.5, 0.05], [[0,1], [0,1], [0, 0.1]],
                  model='Ricker', idx_known_p=[3], known_p=[1])
future_t = list(range(101,151,1))
bd.forecast('Ricker', p_data[-1], future_t, est.p, cov=est.cov,
            p_bounds=[[0,1], [0,1], [0, 0.1]], idx_known_p=[3], known_p=[1],
            percentiles=[90], labels=['$90\\%$'], interval='prediction')

2- Result gives warning

"WARNING:matplotlib.legend:No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument."

and the following image without percentiles: image

krishynan commented 5 months ago

I think I found out how the percentiles list should be given for the function to work.

It looks like you need to provide both the lower and upper bound in the list.

If you want the X% confidence interval, your percentiles list shoud be percentiles=[0, 50-(X/2), 50, 50+(X/2), 100]

I still recommend to add better explanation on how to use the percentiles.