What does The Nightly Funnel conclude, in numbers, about “Non-stationary Traffic: Weekday Effects, Discounted Memory and Sliding Windows”?

Answer: A per-day discount of 0.9 gives B 0.345 in the first week, 0.707 in the second, and settles at 0.843 and 0.847 in the third and fourth, for a total regret of 105.5 orders. A discount of 0.7 reacts faster in the first week, at 0.544, but then hovers around 0.754, 0.763 and 0.730, with a total regret of 129.7 orders: forgetting too fast means paying for exploration all the time. The seven-day window does best: 0.568 in the first week, 0.901 in the third, and a total regret of 87.0 orders.

Scope of the numbers: Its parameters are illustrative; all calculations are generated by its 23 programs; it is general business analysis, not business, legal or financial advice, and it promises no rise in conversion.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 0.345, 0.544, 0.568, 0.7, 0.707, 0.730

ruleshare on B, weeks 1-4 after switchregret
stationary0.0740.1800.3020.423187.9
disc0.90.3450.7070.8430.847105.5
disc0.70.5440.7540.7630.730129.7
window70.5680.8780.9010.84587.0
Show the full program
# Chapter 4. p42: an abrupt switch. For 28 days A pays 0.052 and B
# 0.044; from day 28 on, B pays 0.052 and A 0.044 (a channel mix
# change, illustrative). 1,000 visitors a day in 12 batches, batch
# probability matching as in p41. We report the share of traffic sent
# to B in each of the four weeks after the switch, and total regret.
import math
import random
from statistics import NormalDist

PHI = NormalDist().cdf
DAYS, SWITCH, PER_DAY, BATCHES, REPS = 56, 28, 1000, 12, 30
rng = random.Random(40542)


def p_b(st):
    (sa, fa), (sb, fb) = st
    a1, b1, a2, b2 = 1 + sa, 1 + fa, 1 + sb, 1 + fb
    m1, m2 = a1 / (a1 + b1), a2 / (a2 + b2)
    v1 = a1 * b1 / ((a1 + b1) ** 2 * (a1 + b1 + 1))
    v2 = a2 * b2 / ((a2 + b2) ** 2 * (a2 + b2 + 1))
    return PHI((m2 - m1) / math.sqrt(v1 + v2))


def run(rule):
    st = [[0.0, 0.0], [0.0, 0.0]]
    hist = []
    weeks = [[0, 0] for _ in range(4)]
    reg = []
    per = PER_DAY // BATCHES
    for day in range(DAYS):
        pa, pb = (0.052, 0.044) if day < SWITCH else (0.044, 0.052)
        if rule == "window7":
            st = [[0.0, 0.0], [0.0, 0.0]]
            for h in hist[-7:]:
                for i in range(2):
                    for j in range(2):
                        st[i][j] += h[i][j]
        today = [[0, 0], [0, 0]]
        for _ in range(BATCHES):
            pi = p_b(st)
            for _ in range(per):
                arm = 1 if rng.random() < pi else 0
                p = pb if arm else pa
                y = 1 if rng.random() < p else 0
                today[arm][1 - y] += 1
                st[arm][1 - y] += 1
                reg.append(max(pa, pb) - p)
                if day >= SWITCH:
                    w = (day - SWITCH) // 7
                    weeks[w][0] += arm
                    weeks[w][1] += 1
        hist.append(today)
        if rule.startswith("disc"):
            g = 0.9 if rule == "disc0.9" else 0.7
            for i in range(2):
                for j in range(2):
                    st[i][j] *= g
    return [w[0] / w[1] for w in weeks], math.fsum(reg)


print("rule        share on B, weeks 1-4 after switch     regret")
for rule in ["stationary", "disc0.9", "disc0.7", "window7"]:
    acc, rg = [[] for _ in range(4)], []
    for _ in range(REPS):
        s, r = run(rule)
        for i in range(4):
            acc[i].append(s[i])
        rg.append(r)
    m = [math.fsum(a) / REPS for a in acc]
    print("{:<11} {:>8.3f} {:>8.3f} {:>8.3f} {:>8.3f} {:>13.1f}".format(
        rule, m[0], m[1], m[2], m[3], math.fsum(rg) / REPS))

Single source and citation

Fan, Y. (2026). Autonomous Nightly Funnel Micro-Surgery, Bandit Traffic Allocation and Zero-Touch Conversion Self-Improvement (Version 1.0.0), Chapter 4: Non-stationary Traffic: Weekday Effects, Discounted Memory and Sliding Windows. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 5DL-B-405 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026405,
  author    = {Fan, Yafu},
  title     = {Autonomous Nightly Funnel Micro-Surgery, Bandit Traffic Allocation and Zero-Touch Conversion Self-Improvement},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book