ManticDocs
Read forecasts

Get the probability above or below a value

Sample a forecast run's cumulative distribution to get the probability at or below, or above, an exact numerical or date value.

GET /forecasts/{forecast_id}/cdf samples one run's cumulative distribution function (CDF) at the values you pass as ticks. Pass the run's id, for example latest_forecast.id. The CDF at x is the probability of an outcome at or below x, P(X ≤ x), so the probability above x is 1 - CDF(x).

For dates, and for quantities that move in steps such as a policy rate, "below" and "at or below" differ, so say which you mean.

Sample the CDF

Pass ticks as a JSON-encoded array: numbers for a numerical forecast, ISO 8601 timestamps for a date forecast:

curl --get "https://api.mantic.com/forecasts/988/cdf" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  --data-urlencode 'ticks=[3.5]'

The response is keyed by tick:

{
  "cdf": {
    "3.5": 0.41
  }
}

Here, there's a 41% chance of 3.5 or less, and 59% of more. Keys are strings; for a date forecast, parse them rather than matching the string you sent, as the same instant can be written in more than one way.

In Python, for one numerical run such as latest_forecast:

import json
from typing import Any, Literal

from mantic_client import ManticClient


def probability_at_value(
    client: ManticClient,
    forecast: dict[str, Any],
    value: float,
    side: Literal["at_or_below", "above"],
) -> float:
    if forecast["type"] != "numerical":
        raise ValueError(f"Expected a numerical forecast, got {forecast['type']!r}")
    cdf = client.request(
        "GET", f"/forecasts/{forecast['id']}/cdf", params={"ticks": json.dumps([value])}
    ).json()["cdf"]
    at_or_below = next(iter(cdf.values()))
    return at_or_below if side == "at_or_below" else 1.0 - at_or_below

Get the chance by each date

A date forecast's CDF at a timestamp is the probability that the event has happened by then. Sample several dates, such as month ends, to see how the chance builds:

curl --get "https://api.mantic.com/forecasts/989/cdf" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  --data-urlencode 'ticks=["2026-11-30T23:59:59Z","2026-12-31T23:59:59Z","2027-03-31T23:59:59Z","2027-06-30T23:59:59Z"]'
{
  "cdf": {
    "2026-11-30T23:59:59Z": 0.1,
    "2026-12-31T23:59:59Z": 0.2,
    "2027-03-31T23:59:59Z": 0.41,
    "2027-06-30T23:59:59Z": 0.55
  }
}

Here, there is a 20% chance the event has happened by the end of December, and 55% by the end of June 2027. The values need not reach 1: the rest is the chance it hasn't happened by your last date, including the chance it never does.

Errors

A run with no stored distribution returns 404. ticks that don't match the forecast type, such as numbers for a date forecast, or any ticks for a categorical forecast, return 400.

On this page