Sub topic 8
Variability between runs and how to sample for it
This chapter assumes you know how a tracking workflow turns prompts into parsed responses. It also assumes you can compute mention rate, citation rate, and share of voice from a set of responses. You need to be comfortable with proportions. The Python examples use only the standard library.
Why the same prompt gives different answers
If you send one prompt to an AI answer engine twice, you often get two different answers. A rank tracker can report "position 3" and mean it. An AI visibility tracker cannot report "mentioned: yes" from a single run, because that run is one draw from a distribution.
Several mechanisms produce the differences:
- Sampling inside the model. Models choose each next word from a probability distribution. With a non-zero temperature setting, the wording and the list of brands can change from run to run.
- Retrieval changes. Engines that search the web before answering may fetch different pages, or the same pages in a different order. The cited URLs change even when the prose looks similar.
- Context and personalization. Location, language, account history, and earlier turns in a conversation can all shift the answer.
- Model and index updates. The provider may change the model version or the search index without notice. A change in your metric can then reflect the engine and not your brand.
- Interface differences. The consumer chat interface can apply features such as memory or a built-in search step that a bare API call does not.
The first two are noise you can average out by repeating runs. The last three are systematic. Repetition does not remove them, so you control them through consistent setup and record-keeping.
Treating each run as a trial
For one prompt and one brand, a run either mentions the brand or does not. If the brand appears in 12 of 40 runs, the observed mention rate is 30%. The true rate, meaning the long-run probability that a run mentions the brand, may be higher or lower. With few runs the observed value can sit far from the true one.
A confidence interval states that range. The Wilson interval is a good default for rates because it behaves well with small counts and with rates near 0% or 100%, where the simple "plus or minus" formula fails.
import math
def wilson_interval(successes, trials, z=1.96):
if trials == 0:
return (0.0, 0.0)
p = successes / trials
denom = 1 + z * z / trials
centre = p + z * z / (2 * trials)
margin = z * math.sqrt(p * (1 - p) / trials + z * z / (4 * trials * trials))
return ((centre - margin) / denom, (centre + margin) / denom)
for n in (10, 40, 100, 400):
low, high = wilson_interval(round(0.3 * n), n)
print(f"n={n:>3}: 30% observed, 95% interval {low:.0%} to {high:.0%}")The table shows what that code prints for a 30% observed rate.
| Runs (n) | Mentions | 95% Wilson interval |
|---|---|---|
| 10 | 3 | 11% to 60% |
| 40 | 12 | 18% to 45% |
| 100 | 30 | 22% to 40% |
| 400 | 120 | 26% to 35% |
The width shrinks with the square root of the number of runs. Going from 100 to 400 runs, four times the cost, only halves the interval. A dashboard that shows "30%" from ten runs is showing a number that is consistent with anything from about 11% to 60%.
How many runs you need
For a target margin of error m around a rate p, a standard approximation is:
n ≈ z² × p × (1 − p) / m²
With z = 1.96, p = 0.30, and m = 0.05, this gives about 323 runs. For m = 0.10, it gives about 81. If you have no estimate of p, use 0.5, which is the worst case and gives 385 runs for a five-point margin.
Use this as a planning figure. It assumes runs are independent and identically distributed, and the next sections explain why that assumption often fails.
Prompts are a second source of variation
A tracked prompt set usually contains many prompts, and brands are mentioned far more often for some prompts than for others. A brand might appear in nearly every run of "acme alternatives" and almost never for "how to choose a crm". Part of the uncertainty in your overall mention rate therefore comes from which prompts you happened to pick, and repeating runs does not reduce that part.
This leads to a common error. If you pool 100 prompts × 5 runs and apply the Wilson formula as if you had 500 independent trials, the interval comes out too narrow. Runs of the same prompt resemble each other more than they resemble runs of other prompts.
A prompt-level bootstrap handles this. It resamples whole prompts, with their runs attached, and recomputes the overall rate many times.
import random
def bootstrap_mention_rate(per_prompt, resamples=2000, seed=7):
"""per_prompt maps each prompt to a list of 0/1 mention flags, one per run."""
rng = random.Random(seed)
prompts = list(per_prompt)
rates = []
for _ in range(resamples):
sample = [rng.choice(prompts) for _ in prompts]
hits = sum(sum(per_prompt[p]) for p in sample)
runs = sum(len(per_prompt[p]) for p in sample)
rates.append(hits / runs)
rates.sort()
return rates[int(0.025 * resamples)], rates[int(0.975 * resamples) - 1]
data = {
"best crm for small teams": [1, 1, 1, 0, 1],
"crm with free plan": [0, 0, 0, 0, 0],
"how to choose a crm": [0, 1, 0, 0, 0],
"acme alternatives": [1, 1, 1, 1, 1],
"crm for startups": [0, 0, 1, 0, 0],
"crm pricing comparison": [1, 0, 1, 1, 0],
}
hits = sum(sum(v) for v in data.values())
runs = sum(len(v) for v in data.values())
low, high = bootstrap_mention_rate(data)
print(f"mention rate {hits / runs:.0%}, prompt-level 95% interval {low:.0%} to {high:.0%}")The result is wide because the six prompts behave so differently. That width is an honest statement of how much the set of prompts matters. With only six prompts, treat the interval as rough, since the bootstrap becomes unreliable when there are very few prompts to resample.
Spending a fixed budget: prompts versus repeats
Each run costs money or time, so the total number of runs is capped. You split it between the number of prompts and the number of repeats per prompt.
- More prompts, fewer repeats gives better coverage of topics and intents. It estimates the overall rate better when prompts differ a lot. It tells you little about any single prompt.
- Fewer prompts, more repeats gives stable per-prompt rates. It suits a short list of high-value prompts where you need to know whether a change is real.
A practical split is a broad set run a small number of times, for example 100 prompts × 3 to 5 runs. Add a smaller "watch list" of 10 to 20 important prompts run 20 or more times each. Report the broad set for trends and the watch list for decisions about specific pages.
Comparing two reporting periods
The question people ask is whether the rate went up. A two-proportion z-test gives a quick answer for one prompt or one pooled group.
import math
def two_proportion_z(s1, n1, s2, n2):
p1, p2 = s1 / n1, s2 / n2
pooled = (s1 + s2) / (n1 + n2)
se = math.sqrt(pooled * (1 - pooled) * (1 / n1 + 1 / n2))
if se == 0:
return 0.0, 1.0
z = (p2 - p1) / se
p_value = math.erfc(abs(z) / math.sqrt(2)) # two-sided
return z, p_value
z, p = two_proportion_z(12, 40, 20, 40)
print(f"z={z:.2f}, p={p:.3f}") # about z=1.83, p=0.07A rise from 30% to 50% sounds large, yet with 40 runs per period the p-value is about 0.07. At the usual 0.05 threshold this does not count as a clear change. The test assumes independent runs and a single comparison. If you check 50 prompts, a few will cross the threshold by chance, so treat per-prompt "wins" in a large table as leads to investigate and not as findings.
Controlling what you can control
Averaging removes random noise. Systematic differences need a fixed protocol:
- Keep location, language, device type, and logged-in state the same across periods.
- Start each run in a fresh session so earlier turns cannot influence it.
- Space the repeats out in time. Back-to-back identical requests may hit a cache and return near-copies, which makes your sample look more consistent than the engine is.
- Store the raw response, the cited URLs, the timestamp, and the engine and model identifier shown by the tool. Without them you cannot tell an engine update from a real change.
- Run all engines on the same schedule, and keep your parsing rules (aliases, domain matching) fixed. A change to the rules also changes the metric.
Variability in the other metrics
Mention rate is the simplest to treat as a yes/no trial. The other metrics need more care.
- Citation rate is also a yes/no per run and can use the same intervals. Citations often depend on which pages the engine retrieves in that run, so check on your own data whether they vary more than mentions do.
- Share of voice is a ratio of counts, so noise in the competitors' mentions affects your share too. Compute it from the same runs for every brand, and bootstrap by prompt to get an interval.
- Position and sentiment are not yes/no. Report a median or distribution over the runs where the brand appeared, and note how many runs that was. A "average position 2.1" built from three appearances is weak evidence.
Common errors
- Reporting a single run as the brand's status.
- Applying a run-level interval to pooled prompts and calling the result precise.
- Changing the prompt set, aliases, or engine between periods and still comparing the numbers directly.
- Testing many prompts or brands and highlighting only those that crossed a significance threshold.
- Treating repeated requests sent seconds apart as independent samples.
Exercise
Last month your brand was mentioned in 9 of 30 runs of a watch-list prompt. This month it was mentioned in 15 of 30 runs. Using the two-proportion z-test, is the increase clearly beyond run-to-run noise at the 0.05 level? Also, roughly how many runs would you need to estimate a 30% mention rate to within plus or minus 5 percentage points?
Show answer
The rates are 30% and 50%. The pooled rate is 24/60 = 0.4, so the standard error is sqrt(0.4 × 0.6 × (1/30 + 1/30)) = sqrt(0.016) ≈ 0.126. The z value is 0.2 / 0.126 ≈ 1.58, which gives a two-sided p-value of about 0.11. That is above 0.05, so the increase is not clearly beyond noise. Collect more runs or wait for further periods before acting on it. For a plus or minus 5 point margin at 30%, n ≈ 1.96² × 0.3 × 0.7 / 0.05² ≈ 323 runs.
Exercise
You have a budget of 600 runs per month. Describe one split between prompts and repeats, and say what you would report from each part.
Show answer
One reasonable split is a broad set of 100 prompts run 4 times each (400 runs) plus a watch list of 10 prompts run 20 times each (200 runs). Report the broad set's overall mention rate, citation rate, and share of voice with a prompt-level bootstrap interval, and use it for trends. Report the watch list's per-prompt rates with Wilson intervals, and use it to judge whether a change to a specific page has moved visibility for that prompt.