What does Hidden Markov Models for Customer Decision Stages conclude, in numbers, about “Timing the Offer: the Inquiry as Evidence, a Cost Threshold and Calibration”?

Answer: Chapter 6 gives the timing rule: never speak first, always answer price questions, one price for all, urgency only from reality, and add a quote to other answers only by a calibrated posterior and a cost threshold; counting the inquiry as evidence costs 318.3 per thousand questions against 345.0 from clicks alone, and wrong parameters double premature quotes from 0.0684 to 0.1449.

Scope of the numbers: Marked boxes separate published evidence, runnable Python calculations (18 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: 318.3, 345.0

20000 visits4498 price questions (always answered), 5577 other
ready share among other inquiries0.6595
rule quote rate early/notready miss/ready cost/1k
always quote1.0000 1.0000 0.0000 681.0
never quote0.0000 0.0000 1.0000 659.5
last page SHIP+0.3181 0.1306 0.5851 474.8
clicks only 0.5000.5876 0.2396 0.2327 316.7
clicks only 0.6670.4361 0.1190 0.4002 345.0
with ask0.500 0.7124 0.4034 0.1281 359.2
with ask0.667 0.5779 0.2317 0.2433 318.3
with ask0.800 0.4223 0.1127 0.4179 352.3

Key formula

\[p \ge \frac{c_e}{c_e + c_m}.\]
Show the full program
# Chapter 6. p61: when a reply may carry a quote.
# Model: the four-stage HMM of p11 (illustrative). At every click a
# visitor may open a chat on her own (chance by stage 0.01, 0.03, 0.06,
# 0.10); the first such inquiry ends the simulated visit. A price
# question is always answered with the real price (chance by stage
# 0.10, 0.20, 0.40, 0.60). For any other question the shop decides
# whether to add a quote to its answer. Ready = compare or decide at
# that click. A quote to a visitor not ready is premature (cost 2); no
# quote to a ready visitor is a miss (cost 1); Bayes cut 2/(2+1).
# The posterior is taken from the clicks alone, and again with the
# inquiry itself counted as evidence (ready visitors ask more often).
# No rule ever sends a message the visitor did not ask for.
import math
import random

PI = [0.70, 0.20, 0.08, 0.02]
A = [[0.70, 0.22, 0.06, 0.02],
     [0.08, 0.64, 0.23, 0.05],
     [0.02, 0.10, 0.66, 0.22],
     [0.01, 0.03, 0.16, 0.80]]
B = [[0.45, 0.30, 0.08, 0.07, 0.06, 0.04],
     [0.15, 0.35, 0.25, 0.12, 0.08, 0.05],
     [0.08, 0.22, 0.15, 0.30, 0.17, 0.08],
     [0.05, 0.12, 0.08, 0.15, 0.30, 0.30]]
ASK = [0.01, 0.03, 0.06, 0.10]
PRICE_Q = [0.10, 0.20, 0.40, 0.60]
C_EARLY, C_MISS = 2.0, 1.0
K = 4


def draw(rng, probs):
    u, acc = rng.random(), 0.0
    for k, p in enumerate(probs):
        acc += p  # step
        if u < acc:
            return k
    return len(probs) - 1


rng = random.Random(20261113)
cases = []
n_visits = 20000
n_price = 0
for _ in range(n_visits):
    s = draw(rng, PI)
    f = None
    for t in range(14):
        if t:
            s = draw(rng, A[s])
        o = draw(rng, B[s])
        if f is None:
            f = [PI[k] * B[k][o] for k in range(K)]
        else:
            f = [math.fsum(f[i] * A[i][j] for i in range(K)) * B[j][o]
                 for j in range(K)]
        z = math.fsum(f)
        f = [x / z for x in f]
        if rng.random() < ASK[s]:
            if rng.random() < PRICE_Q[s]:
                n_price += 1  # step
            else:
                # 发问本身也是证据:乘上各阶段「发问且非问价」的概率
                g = [f[k] * ASK[k] * (1 - PRICE_Q[k]) for k in range(K)]
                cases.append((s >= 2, math.fsum(f[2:]), o >= 4,
                              math.fsum(g[2:]) / math.fsum(g)))
            break
n = len(cases)
n_ready = len([1 for c in cases if c[0]])
print("%d visits: %d price questions (always answered), %d other"
      % (n_visits, n_price, n))
print("ready share among other inquiries: %.4f" % (n_ready / n))
print("rule              quote rate  early/notready  miss/ready  cost/1k")
rules = [("always quote", lambda c: True),
         ("never quote", lambda c: False),
         ("last page SHIP+", lambda c: c[2])]
for th in (0.5, C_EARLY / (C_EARLY + C_MISS)):
    rules.append(("clicks only %.3f" % th,
                  lambda c, th=th: c[1] >= th))
for th in (0.5, C_EARLY / (C_EARLY + C_MISS), 0.8):
    rules.append(("with ask   %.3f" % th,
                  lambda c, th=th: c[3] >= th))
for name, rule in rules:
    q = [rule(c) for c in cases]
    early = len([1 for c, x in zip(cases, q) if x and not c[0]])
    miss = len([1 for c, x in zip(cases, q) if c[0] and not x])
    cost = (C_EARLY * early + C_MISS * miss) / n * 1000
    print("%-17s %10.4f  %14.4f  %10.4f  %7.1f"
          % (name, len([1 for x in q if x]) / n, early / (n - n_ready),
             miss / n_ready, cost))

Single source and citation

Fan, Y. (2026). Hidden Markov Models and Viterbi Decoding: Inferring a Customer's Hidden Decision Stage from Click Sequences and Timing the Offer (Version 1.0.0), Chapter 6: Timing the Offer: the Inquiry as Evidence, a Cost Threshold and Calibration. 5D Library. DOI pending

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

BibTeX
@book{fan2026300,
  author    = {Fan, Yafu},
  title     = {Hidden Markov Models and Viterbi Decoding: Inferring a Customer's Hidden Decision Stage from Click Sequences and Timing the Offer},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book