liveBook · Manning

Predictive distribution

As explained in Time Series Forecasting Using Foundation Models

A predictive distribution is a probability distribution over possible future values conditional on observed input data.

A predictive distribution assigns probabilities to possible future values conditional on observed input data. In forecasting, sampled future paths preserve uncertainty rather than returning only one estimate. section 4.2.2

Lag-Llama generates an output distribution by sampling future time steps. Increasing the sample count generally produces a more precise distribution, while the context length controls the historical input window. section 4.2.2

Weekly sales forecast

A zero-shot Lag-Llama workflow loads Walmart weekly sales, formats stores as series, predicts eight weeks on a CPU, and summarizes samples with medians and 95% prediction intervals. section 4.2.2

Listing 4.7 Function to format the output as a DataFrame
import numpy as np

def get_median_and_ci(data,
                      start_date,
                      horizon,
                      freq,
                      id,
                      confidence=0.95):

    n_samples, n_timesteps = data.shape

    medians = np.median(data, axis=0)  #1

    lower_percentile = (1 - confidence) / 2 * 100  #2
    upper_percentile = (1 + confidence) / 2 * 100


    lower_bounds =
    ➥np.percentile(data, lower_percentile,
    ➥ axis=0)  #3
    upper_bounds = np.percentile(data, upper_percentile, axis=0)

    pred_dates = pd.date_range(start=start_date, periods=horizon,
   ➥freq=freq)  #4
    formatted_dates = pred_dates.strftime('%m-%d-%Y').tolist()

    df = pd.DataFrame({
        'Date': formatted_dates,
        'Store': id,
        'Lag-Llama': medians,
        f'Lag-Llama-lo-{int(confidence*100)}': lower_bounds,
        f'Lag-Llama-hi-{int(confidence*100)}': upper_bounds
    })

    return df

Inspect the implementation that computes medians and percentile bounds from forecast samples, then formats dates and interval columns. section 4.2.2

How Time Series Forecasting Using Foundation Models covers it

How deep it goes
Explains sampling, context length, medians, and percentile intervals, but does not derive the underlying probability model.
Examples
Demonstrates eight-week Walmart store sales forecasts summarized by medians and 95% prediction intervals.
What it assumes
Assumes a forecasting dataset and basic Python workflow, while exposing context windows, samples, medians, and percentiles through implementation.
What you can do after
Apply it via Lag-Llama and Python to generate, summarize, and visualize probabilistic forecasts.
How it connects
Connects predictive distributions with zero-shot forecasting, Lag-Llama, prediction intervals, and GluonTS predictors.

Also explained in

Compare how 2 books explain predictive distribution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Time Series Forecasting Using Foundation Models. The section links point to the parts of the book it draws on.