Skip to main content

Part of WatEase, India’s agentic AI commerce and marketing platform

Thompson Sampling

A Bayesian way to split traffic between options — creatives, templates, audiences — that sends most of it to the likely best one while still testing the rest.

Last updated

Definition

Thompson Sampling is an algorithm for the multi-armed bandit problem: you have several options — ad creatives, message templates, audiences, send times — and want most of your traffic on the best one without knowing in advance which that is. It keeps a probability distribution over each option's true success rate. For a yes/no outcome (clicked or not, replied or not) that distribution is a Beta: after s successes and f failures, the belief about an option is Beta(s + 1, f + 1). For every decision it draws one random value from each option's distribution and picks the option with the highest draw. That single rule balances exploring and exploiting on its own. An option with plenty of evidence and a high rate draws high values most of the time and wins most of the traffic. An option with little evidence has a wide distribution, so it still wins now and then — which is how it gets tested — and stops winning once its evidence shows it is worse. Take two WhatsApp templates: A with 30 replies from 1,000 sends, Beta(31, 971), tightly around 3%; and B with 4 replies from 100, Beta(5, 97), around 5% but far wider. B often draws higher than A, so it gets a real share of the next sends, and as its evidence grows the split settles on whichever template is actually better. A fixed A/B test splits traffic evenly until the end and then picks a winner; Thompson Sampling sends less traffic to the losers along the way. The price is precision: it is built to maximise results during the test, not to measure the size of the difference. Compared with ε-greedy (explore a fixed share at random) and UCB (always pick the most optimistic option), it usually explores less wastefully and copes well when results arrive in batches rather than one at a time.

How it applies in India

Testing on WhatsApp costs more per trial than testing on email. Every marketing template delivered to an Indian number is billed — ~₹0.8631 at Meta's current India marketing rate — and each one uses up part of that customer's per-user marketing allowance across all businesses. Sends wasted on a losing variant are therefore expensive, which is exactly the case Thompson Sampling is built for: it moves sends to the better template as soon as the results start to separate, instead of holding a 50/50 split to the end. Meta runs a version of the same idea on its side. Under template pacing, a new or edited marketing template is first delivered to part of its audience, and the rest is released only if early feedback — blocks and reports — stays healthy, so a variant customers block can be held back before your own test has finished.

Frequently asked questions

Is Thompson Sampling better than A/B testing?

For earning while you test, usually; for measuring, no. An A/B test holds a fixed split so it can estimate the difference between variants with a known confidence. Thompson Sampling moves traffic toward the leader as it goes, so fewer customers see the loser, but the estimate of how much worse the loser was is less precise. Use an A/B test when you need the number — a price change you will have to defend — and a bandit when you need the result, such as which festive template the rest of the list should get.

What should count as a success?

An event that happens soon after the send and tracks what you actually want. For WhatsApp templates that is usually a reply or a button tap within a day. A purchase is a better signal if it arrives quickly; a reward that lands a week later leaves the algorithm deciding on stale evidence.

Why does it keep sending traffic to an option that looks worse?

Because the evidence does not rule it out yet. An option with few results has a wide distribution, so it sometimes draws the highest value. Each of those sends narrows the distribution, and once the option is clearly worse it almost never wins a draw.

Related terms

Try WatEase

Run your WhatsApp commerce on the platform built for India — Cloud API, GST invoices, UPI checkout, opt-in tracking, and 0% markup on WhatsApp messages (competitors add 20–25%). Pricing is on request — quoted by the WatEase team.

Get Started Today