八边形边上取点
Dot Placement
题目详情
你沿着八边形的边缘随机放置三个点。所有三个点都位于八边形的不同边上的概率是多少?
You place three dots along the edges of an octagon at random. What is the probability that all three dots lie on distinct edges of the octagon?
解析
让我们考虑将每个点逐一放置。默认情况下,第一个点将放置在八边形的不同边缘上。
对于要放置在不同边缘上的第二个点,必须将其放置在除放置第一个点的边缘之外的任何边缘上。由于总共有 8 条边,因此我们有 7 种边选择来放置第二个点。
最后一个点必须放置在除放置这些点的前两个边缘之外的任何边缘上。这给我们留下了 6 种边的选择。
将这三个事实结合在一起,我们得到所有三个点位于不同边缘上的总概率为
这是验证此结果的 python 模拟:
import random
# Place 3 dots randomly on 1 of 8 sides
simulation = lambda: len(set([random.randint(1, 8) for _ in range(3)])) == 3
# Run 10,000 simulations
simulations = [simulation() for _ in range(10_000)]
# Find the proportion of simulations in which all three dots are placed on a unique edge
print(f"Answer: {sum(simulations) / len(simulations)}")Original Explanation
Let's consider placing each dot one by one. The first dot will be placed on a distinct edge of the octagon by default.
For the second dot to be placed on a distinct edge it must be placed on any edge other than the edge upon which the first dot was placed. Since there are a total of 8 edges, this leaves us with 7 choices for edges to place the second dot.
The final dot must be placed on any edge other than the first two edges upon which the dots were placed. This leaves us with 6 choices for edges.
Combining these three facts together, we get that the total probability that all three dots lie on distinct edges is
Here is a python simulation that validates this result:
import random
# Place 3 dots randomly on 1 of 8 sides
simulation = lambda: len(set([random.randint(1, 8) for _ in range(3)])) == 3
# Run 10,000 simulations
simulations = [simulation() for _ in range(10_000)]
# Find the proportion of simulations in which all three dots are placed on a unique edge
print(f"Answer: {sum(simulations) / len(simulations)}")