I am trying to implement boostrap prediction interval example of FPP3 book in python for learning purposes (https://otexts.com/fpp3/prediction-intervals.html).

Prediction interval is estimated by simulating 5000 sample paths along forecasting horizon (h = 10). For each horizon and each path, random error (== residual in this case) value is sampled from collection of 252 known values and added to the previous forecasted value, leading to a random path each time. After that, for each horizon, lower and upper percentiles of the values of 5000 paths are calculated to get prediction interval at certain probability (i.e. 95%).

Data set: 2015 Google stock closing price, 252 businness days. Forecast horizon: 10 days. Model: Naive. Residuals: 252 values -> (observation value - naive model prediction) for each day.

bootstrap = []
for i in range(0, 5000):
    path = []
    for j in range(0, 10):
        e = random.choice(list(residuals.values))
        if (j == 0):
            path[j] = path[j] + e
            path[j] = path[j-1] + e
df = pd.DataFrame(bootstrap)

Finally, I have dataframe 'df':

enter image description here

Prediction intervals are calculated based on percentiles for each forecasting horizon:

path_l = []
path_h = []
ser = df.quantile(0.025, axis = 0)
ser = ser.set_axis(path_l.index)
ser = df.quantile(0.975, axis = 0)
ser = ser.set_axis(path_h.index)

Normality check of distribution of simulated values (paths) for each forecasting horizon:

for i in range(0, 10):
    a = df[i].tolist()
    figure = plt.figure()
    figure.suptitle('histogram_bootstrap_step_' + str(i+1))
    plt.hist(a, bins = 30)
    print(str(i+1) + ". step")

Regarding bootstrapped prediction intervals, according to the histogram of samples drawn of residuals at a certain forecasting horizon (lets say h = 10 , last forecast), it seems that values could be normally distributed. However, normality tests (Anderson-Darling, Jarques-Bera) definitely show that distribution of drawn residuals is not normal, statistic values are much higher than required to reject the null hypothesis:

enter image description here

10. step
Jarque_beraResult(statistic=1390.292955526538, pvalue=0.0)
AndersonResult(statistic=47.28770856219671, critical_values=array([0.576, 0.655, 0.786, 0.917, 1.091]), significance_level=array([15. , 10. ,  5. ,  2.5,  1. ]))

Idk if the non-normality causes problem when taking percentiles as lower/upper prediction intervals.

Shortly, question is that is it required the bootrapped prediction interval to be normally distributed? Last graph ("Bootstrap intervals from the naïve method") on page:


Thank you very much.

  • $\begingroup$ Could u help me with where you got the residual values from, (observation value - naive model prediction) Naive model prediction will give u predictions for the 10 forecasted horizon so how did u get it for the other 252 values? Thanks if u could share the whole code with me. $\endgroup$ Dec 21, 2023 at 1:10

1 Answer 1


No, bootstrapped predictive distribution are not necessarily normally distributed. In general, they should follow the in-sample conditional distributions (which are, of course, hard to observe).

As an illustration, assume that we are forecasting a low volume count time series, like retail sales on a SKU/day/store levels. This can reasonably be modeled using a negative binomial distribution, which is quite skewed. The simple bootstrap will of course not yield integer numbers (unless you round), but it will yield something quite skewed - and certainly not normal.

Whether any given bootstrapped predictive distribution is normal will depend on the time series you feed in.

  • $\begingroup$ Thank you very much sir! $\endgroup$
    – EEEE77
    Nov 17, 2021 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.