Simulate contextual thompson bandit

Simulate Bayesian contextual Thompson sampling and quantify intervention reward, regret, and policy uncertainty.

What it's for

Quantifies what a learn-while-you-decide rollout would earn and what it would cost in regret, before you run it on a real team.

Turns management experiments into an adaptive, measurable intervention policy rather than static advice.

What you give it

Inputs split into evidence read from your connected systems, calibration your team owns, and numerical controls that affect precision but never the result's meaning.

Field Type Role Required
arms array of objects (1 field) Evidence Yes
events array of objects (2 fields) Evidence Yes
observation_noise number > 0 Your calibration Optional
prior_precision number > 0 Your calibration Optional
recent_window integer ≥ 1 Your calibration Optional
seed integer Numerical control Optional
simulations integer ≥ 20 Numerical control Optional

Each events record

Field Type Required
context array of number (≥ 1 item) Yes
rewards object Yes
Example input
{
  "arms": [
    {
      "id": "wip_limit"
    },
    {
      "id": "status_quo"
    }
  ],
  "events": [
    {
      "context": [
        1,
        0.1
      ],
      "rewards": {
        "status_quo": 0.2,
        "wip_limit": 1.1
      }
    },
    {
      "context": [
        1,
        0.3
      ],
      "rewards": {
        "status_quo": 0.2,
        "wip_limit": 1.3
      }
    },
    {
      "context": [
        1,
        0.5
      ],
      "rewards": {
        "status_quo": 0.2,
        "wip_limit": 1.5
      }
    },
    {
      "context": [
        1,
        0.7

Truncated for display — the full payload is 65 lines.

What you get back

This is the actual output of running the example above — computed by the same function the platform calls, not an illustration.

Example output
{
  "arms": [
    {
      "id": "wip_limit",
      "posterior_mean_coefficients": [
        0.6958,
        1.134
      ],
      "recent_selection_probability": 0.69,
      "selection_probability": 0.69
    },
    {
      "id": "status_quo",
      "posterior_mean_coefficients": [
        0.0879,
        0.0661
      ],
      "recent_selection_probability": 0.31,
      "selection_probability": 0.31
    }
  ],
  "assumptions": [
    "Event rewards contain full counterfactual feedback for simulation; online production updates observe only the chosen arm.",
    "Rewards should include operational benefit minus intervention and side-effect costs on one common scale."
  ],
  "cumulative_regret": {
    "p10": 0,
    "p50": 2,
    "p75": 2.55,
    "p90": 3.3
  },
  "cumulative_reward": {
    "p10": 4.2,
    "p50": 5.5,
    "p75": 6.6,
    "p90": 7.5
  },
  "method": "contextual_thompson_simulation_v1",
  "probability_outperform_uniform": 0.9,
  "recommended_arm": "wip_limit",
  "simulation": {
    "context_dimension": 2,
    "observation_noise": 1,
    "prior_precision": 1,

Truncated for display — the full payload is 54 lines.

How it works

Sequential Bayesian & bandits — Learn while deciding — update beliefs as evidence arrives and choose where the next unit of effort is worth spending.

  1. 1 Simulate Bayesian contextual Thompson sampling and quantify intervention reward, regret, and policy uncertainty.
  2. 2 Evaluate the method-specific diagnostics and gates returned by the function, then abstain unless the declared decision clears them under locally governed thresholds.

Before you trust it

Every tool in the catalog ships with the conditions under which its answer is meaningful — and the conditions under which it should abstain instead of guessing.

Assumptions & guardrails

  • The likelihood or reward model, prior support, action logging, delayed outcomes, and any stationarity assumptions match the deployment process.
  • Posterior probability and adaptive selection are model-conditional; they are not substitutes for randomized propensities or guaranteed safety.

Minimum evidence

  • arms: required and organization-defined
  • events: required and organization-defined

How to validate it

Backtest the chosen action against simple feasible baselines on held-out scenarios, sweep costs/constraints/risk tolerance, and require constraint feasibility under adverse inputs.

Calibrating it to your org

Same for everyone

The mathematical kernel, validation rules, method version, and JSON output semantics are organization-independent; no tenant-trained coefficients or company benchmark is embedded in the function.

Specific to you

  • metric/outcome definitions, entity grain, observation window, costs, thresholds, priors, and constraints represented by the function inputs

Calibration workflow

  1. 1 Define the management decision, target outcome, aggregate unit, privacy boundary, cadence, and prediction/intervention horizon for this organization.
  2. 2 Build a tenant-scoped historical cohort using only information available before each prediction or decision; preserve zero periods, censoring, assignment probabilities, and unresolved outcomes when the method requires them.
  3. 3 Estimate statistical parameters on training history, but obtain costs, utilities, risk tolerance, practical-effect thresholds, capacity, and policy constraints from accountable decision owners.
  4. 4 Validate on later time windows or held-out aggregate units at the deployment grain, against a simple baseline and the function-specific validation strategy.
  5. 5 Deploy only if the returned decision clears evidence, overlap, calibration, robustness, and guardrail checks; warning, unsupported, schema-gap, and fallback decisions are abstentions.
  6. 6 Monitor realized outcomes, data drift, coverage, and decision regret; recalibrate at a governed cadence or after a detected regime/definition change, never merely because a stakeholder dislikes the result.

Call it from your AI

You don't wire up 388 tools in your MCP client. The GitRevio MCP server exposes 18 tools, three of which let an agent search the catalog, read a tool's schema, and run it — so the assistant finds this one on its own.

gitrevio_capabilities_search
  { "q": "simulate bayesian contextual thompson sampling and" }
  → finds "simulate_contextual_thompson_bandit"

gitrevio_capability_describe
  { "capability_id": "simulate_contextual_thompson_bandit" }
  → returns the input schema and agent guidance shown on this page

gitrevio_capability_run
  { "capability_id": "simulate_contextual_thompson_bandit", "arguments": { ... } }
  → returns the result shown above

Works in Claude Desktop, Claude Code, Cursor, Cline, Continue.dev, Goose and Aider. See the MCP server.

Related tools

Fit team behavior regime HMM

Learn persistent privacy-safe team operating regimes and transitions with a Gaussian hidden Markov model.

Markov & state-space control

MCMC project completion forecast

Forecast live task and project completion with a censored Bayesian lognormal model, MCMC uncertainty, dependencies, and finite parallelism.

Sequential Bayesian & bandits

Optimize workforce policy tree

Optimize staged team/role capacity actions through uncertain demand by Monte Carlo backward induction.

Constrained optimization

Audit causal claim negative controls

Gate a causal effect claim using prespecified negative outcome/exposure controls, Benjamini-Hochberg multiplicity control, and an omnibus chi-square falsification test.

Causal inference & experiment design

Audit cluster randomization integrity

Audit cluster-randomized experiments for practical baseline imbalance and differential outcome observation, with cluster-size-weighted standardized differences and assignment permutation diagnostics.

Causal inference & experiment design

Audit growth incrementality experiment integrity

Audit aggregate randomized growth experiments before anyone trusts channel incrementality: enforce unique experimental units, nondegenerate logged propensities, both arms, control-spend discipline, baseline balance, spillover and evidence gates; then estimate propensity-weighted baseline-adjusted contribution, cluster-unit bootstrap uncertainty and incremental return on spend.

Causal inference & experiment design

See every tool in Causal evidence & experiments →

Ready to See Your Engineering work clearly?

Request a free demo