EN: The rules are simple: I pick an integer from 0 to 100, and you guess one number at a time. I can only answer with three words — “too low”, “too high”, or “correct!”
EN: Now let's switch roles: YOU think of a number from 0 to 100, and let the machine guess it. Tap a spot on the number bar (or press “Pick a random one”), then watch the machine close in step by step — keep an eye on how the green interval shrinks! 👇
🎮 小游戏:机器猜你心里想的数 · Mini-Game: The Machine Reads Your Mind
① 在数字条上点一个数(或点「随机想一个」)→ ② 点「开始猜!」→ ③ 看区间一步步收缩 EN: ① tap the number bar (or “Pick a random number”) → ② press “Start” → ③ watch the range shrink step by step
🎯 你心里想的数:50Your number: 50
?
0255075100
🔻 大了!往左找Too high — go lower🔺 小了!往右找Too low — go higher🎯 用了 ? 次猜中了!It took ? guesses to find it!第 0 次 · Guess #0
EN: Think of a number from 0 to 100 and watch the machine narrow it down by always cutting the remaining range in half.
2 · 为什么「砍半」这么厉害?
🧠 先停下来想一想:0~100 猜数,只有「砍半」这一种办法吗?还有其他更好的方法吗?
Are there OTHER ways to play — or even better ones? Think first before you read on!
EN: Your turn: rank the four strategies — and try to invent a faster one. Spoiler: next section proves 7 is the game's hard limit, not a lucky coincidence.
EN (for kids): Each “higher/lower” answer doubles how many numbers you can handle. Doubling 1→2→4→…→128 takes 7 steps, and 128 ≥ 101. So 7 guesses always suffice.
任何猜数策略,最坏情况都 ≥ 7 次EN: No strategy in the world can guarantee success in fewer than 7 guesses.
而二分查找每次回答都恰好提供满 1 bit(范围严格对半),所以它达到下界 = 最优算法。
一般化:N 个数猜一个,最坏需要 ⌈log₂ N⌉ 次。
EN: Each answer carries at most 1 bit. Distinguishing 101 possibilities needs ⌈log₂101⌉ = 7 bits, so no strategy can beat 7 worst-case guesses — and binary search achieves it.
EN: Each black bubble marks the cutting point, always pressed against the FRONT of the colored strip — everything to its left turns grey (excluded), the colored part is what remains. The strip shrinks 101→50→25→12→6→3→1; after the 7th cut only the cell “100” is left.
树上每一个数字就是一个节点,数字在第几层,猜到它就要几次:根 50 在第 1 层 → 1 次就中;第 2 层的 24、75 → 2 次;第 3 层的 11、37、62、88 → 3 次。EN: A number on level k needs k guesses — the tree tells you instantly.
EN: Every node has 2 children, so each level doubles: 1, 2, 4, 8, 16, 32 — and finally 38 at depth 7, because 101 − 63 = 38: the tree cannot be filled completely. Total: exactly 101.
⚠️ 重要:这张表有「前提条件」!这个 1、2、4、8、16、32、38 的形状,不是猜数游戏的普遍规律,而是两个条件同时成立时才出现:
① 特定游戏:0~100 共 101 个数,一次只猜一个,回答只有「大了 / 小了 / 猜中」;
② 特定算法:用二分查找(每次都猜正中间)。
只要换一样,分布就完全变样:换成顺序查找 → 1~100 次几乎均匀分布;换成随机乱猜 → 靠运气、还可能重复;范围换成 0~1000 → 还是翻倍形状,但最深到第 10 层(⌈log₂1001⌉ = 10)。
结论:分布的形状 = 游戏规则 × 算法,两者一起决定。EN: This distribution is NOT universal — it holds only for THIS game (0–100, three answers) played with binary search. Change the game or the strategy and the shape changes completely.
EN: This histogram shows one real run of 3000 random games: 34, 67, 115, 243, 478, 955, 1108 games needed 1, 2, …, 7 guesses. Expect ≈30, ≈59, …, ≈1129 — random runs wiggle a little, but the doubling shape 1:2:4:8:16:32:38 stays.
🎯 离散分布 Discrete distribution:随机变量只能取有限个 / 可数个孤立数值(整数居多),用来描述计数类、次数类、个数类的随机现象。 EN: A discrete distribution describes random variables that take finite or countable isolated values (mostly integers) — used for counting-type random phenomena.
🔙 回到猜数游戏:我们这篇的「猜几次」其实也是一种离散分布——只不过它不是上面四种经典模型,而是由「砍半的树」决定的。但它一样能算概率:第 k 次猜中的概率 = 第 k 层的数字个数 ÷ 101(比如 7 次才中的概率 = 38 ÷ 101 ≈ 37.6%)。
EN: Discrete distributions answer counting questions: probability of exactly k successes (Binomial), rare events per unit time (Poisson), trials until first success (Geometric), and draws without replacement (Hypergeometric). Our guessing-count distribution is discrete too — P(k-th guess hits) = level k size / 101.
微积分:神经网络梯度下降优化。 EN: gradient-descent optimization in neural networks.
🔗 一个串联小例子(把三门数学串起来):
① 离散数学先算:从 100 个产品里抽 5 个,总共有 C(100,5) 种抽法(数方案);
② 概率论接着算:随机抽取恰好抽到 2 个次品的概率(用上面那个组合数算可能性);
③ 微积分最后上:当样本极大时,用连续的正态分布去近似这个离散概率(连续近似离散)。
EN: ① Discrete math counts C(100,5) possible draws. ② Probability turns that count into the chance of exactly 2 defects. ③ Calculus approximates the discrete answer with a normal curve when samples are huge.