What does Anti-Spam Detection and Compliant Bridge Pages conclude, in numbers, about “A Few Posts Are Enough: Likelihood Ratios, Sequential Tests and Change-Point Alarms”?

Answer: Chapter 2 computes sample sizes with the likelihood ratio and Wald's sequential test; even a Poisson timer needs only 15 gaps.

Scope of the numbers: Its parameters are illustrative; all calculations are generated by its programs; it is general business analysis, not personalised business, legal or financial advice, and rules must be checked by a human reviewer before publication. Marked boxes separate published evidence, runnable Python calculations (20 programs), classical sources and the author's hypotheses.

中文版

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: 15

shape k D(f1||f0) mu0 s0 s1 n gaps alpha power
1002.765 -200.359 189.674 0.700 5 0.000 1.000
91.614 -16.039 16.731 0.621 6 0.003 1.000
20.982 -2.552 3.465 0.697 8 0.004 0.978
10.612 -0.899 1.621 0.833 15 0.004 0.989
k 100: fixed timer; k 9: loose timer; k 1: Poisson timer
target alpha 0.01 and power 0.99; accounts per check2,000
Show the full program
# Chapter 2. p21: Neyman-Pearson likelihood ratio and fixed sample size.
# Model: the detector compares two densities for one inter-post gap t
# (hours): human-like f0 = 0.6 Exp(mean 0.25) + 0.4 LogNormal(ln 8, 1.0)
# and a scheduler f1 = Gamma(shape k, mean 6). Per gap the log
# likelihood ratio L = ln f1(t) - ln f0(t) has mean mu1 and sd s1 when
# the account is a scheduler and mu0, s0 when it is human; mu1 is the
# Kullback-Leibler divergence D(f1||f0). With alpha = beta = 0.01 the
# normal approximation gives n = ((z s0 + z s1) / (mu1 - mu0))^2 gaps.
# Integrals by Simpson's rule on u = ln t. A seeded check draws 2,000
# accounts of each kind at that n. Parameters are illustrative.
import math
import random
import statistics

Z = statistics.NormalDist().inv_cdf(0.99)


def log_f0(t):
    a = math.log(0.6) + math.log(4.0) - 4.0 * t
    z = (math.log(t) - math.log(8.0)) / 1.0
    b = math.log(0.4) - math.log(t * math.sqrt(2 * math.pi)) - z * z / 2
    m = max(a, b)
    return m + math.log(math.exp(a - m) + math.exp(b - m))


def log_f1(t, k):
    th = 6.0 / k
    return ((k - 1) * math.log(t) - t / th - math.lgamma(k)
            - k * math.log(th))


def moments(k, under):
    lo, hi, m = math.log(1e-4), math.log(400.0), 4000
    h = (hi - lo) / m
    w0, w1, w2 = [], [], []
    for i in range(m + 1):
        u = lo + i * h
        t = math.exp(u)
        lf = log_f1(t, k) if under == 1 else log_f0(t)
        dens = math.exp(lf) * t
        c = 1 if i in (0, m) else (4 if i % 2 else 2)
        llr = log_f1(t, k) - log_f0(t)
        w0.append(c * dens)
        w1.append(c * dens * llr)
        w2.append(c * dens * llr * llr)
    tot = math.fsum(w0)
    mu = math.fsum(w1) / tot
    return mu, math.sqrt(math.fsum(w2) / tot - mu * mu)


def human_gap(rng):
    if rng.random() < 0.6:
        return rng.expovariate(4.0)
    return rng.lognormvariate(math.log(8.0), 1.0)


def check(rng, k, n, c, reps=2000):
    fp = tp = 0
    for _ in range(reps):
        s = math.fsum(log_f1(g, k) - log_f0(g)
                      for g in (human_gap(rng) for _ in range(n)))
        fp += s > c
        s = math.fsum(log_f1(g, k) - log_f0(g)
                      for g in (rng.gammavariate(k, 6.0 / k)
                                for _ in range(n)))
        tp += s > c
    return fp / reps, tp / reps


if __name__ == "__main__":
    rng = random.Random(20261122)
    print("shape k  D(f1||f0)  mu0      s0     s1     n gaps  alpha  power")
    for k in (100.0, 9.0, 2.0, 1.0):
        mu1, s1 = moments(k, 1)
        mu0, s0 = moments(k, 0)
        n = math.ceil(((Z * s0 + Z * s1) / (mu1 - mu0)) ** 2)
        c = n * mu0 + Z * s0 * math.sqrt(n)
        a, p = check(rng, k, n, c)
        print("{:>7.0f} {:>10.3f} {:>7.3f} {:>6.3f} {:>6.3f} {:>8} "
              "{:>6.3f} {:>6.3f}".format(k, mu1, mu0, s0, s1, n, a, p))
    print("k 100: fixed timer; k 9: loose timer; k 1: Poisson timer")
    print("target alpha 0.01 and power 0.99; accounts per check: {:,}"
          .format(2000))

Single source and citation

Fan, Y. (2026). Social-Graph Anti-Spam Detection Bounds, Compliant Affiliate Bridge-Page Funnels and the Kinetics of Recovery after Reach Throttling (Version 1.0.0), Chapter 2: A Few Posts Are Enough: Likelihood Ratios, Sequential Tests and Change-Point Alarms. 5D Library. DOI pending

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

BibTeX
@book{fan2026342,
  author    = {Fan, Yafu},
  title     = {Social-Graph Anti-Spam Detection Bounds, Compliant Affiliate Bridge-Page Funnels and the Kinetics of Recovery after Reach Throttling},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book