Prepare a controlled experiment
Define a discrete set of candidate policy actions and, initially, simple synthetic reward-generating processes to validate the pipeline.
Simulate policy actions. Estimate expected rewards.
This project demonstrates a simple simulation for comparing discrete policy actions using an epsilon-greedy multi-armed bandit. The code treats each action as a Bernoulli arm with a fixed true reward probability and updates sample-average estimates online. Important real-world considerations include state dependence, confounding between actions and external factors, data provenance and safety constraints.
Learning concept · Not a validated service
This project demonstrates a simple simulation for comparing discrete policy actions using an epsilon-greedy multi-armed bandit. The code treats each action as a Bernoulli arm with a fixed true reward probability and updates sample-average estimates online. Important real-world considerations include state dependence, confounding between actions and external factors, data provenance and safety constraints.
A proposed use: help analysts run quick exploratory comparisons of candidate policy options under simplified assumptions, producing estimated reward rates and sample counts as a starting point for deeper causal analysis. For any real policy evaluation, keep a human analyst in the loop and do not use the prototype for operational decisions.
Define a discrete set of candidate policy actions and, initially, simple synthetic reward-generating processes to validate the pipeline.
Specify reward semantics (here: Bernoulli success probability per action) and which metrics to track such as cumulative reward and per-action counts.
Use an epsilon-greedy bandit loop to alternately explore and exploit, update sample-average estimates online, and collect outcomes.
Inspect estimated rates and action counts, then plan extensions: richer state, contextual features, real economic data and safety constraints.
The supplied starter runs an epsilon-greedy multi-armed bandit simulation over four Bernoulli 'actions' with fixed true success probabilities. It selects actions by exploration with probability epsilon or by greedy argmax, observes binary rewards sampled from the true rates, updates sample-average estimated reward rates, and prints action counts, estimated rates and total reward.
for step in range(1, 2001):
if rng.random() < epsilon:
action = rng.integers(len(true_reward_rates))
else:
action = int(np.argmax(estimated_values))
reward = 1 if rng.random() < true_reward_rates[action] else 0
action_counts[action] += 1
total_reward += reward
estimated_values[action] += (reward - estimated_values[action]) / action_counts[action]The starter uses four synthetic Bernoulli arms and no economic data, state, features or causal model. It does not implement a policy-gradient or environment with state transitions, nor does it evaluate financial metrics such as Sharpe ratio or drawdown. Results from this toy run do not validate any real economic policy.
A proposed extension is a scenario-driven simulator that replaces synthetic arms with policy interventions modelled from historical economic indicators and counterfactual assumptions, lets analysts vary assumptions, and reports multiple metrics with uncertainty and human-review workflows.
This is a potential application pathway, not a delivered product. The supplied starter does not implement this service or validate it with real users.
Networkers Home runs this topic inside its AI Engineer Course, with placement support and hands-on labs.