Add files via upload
This commit is contained in:
parent
3eff6ccae6
commit
9640a0a30b
@ -12,9 +12,15 @@
|
||||
"\n",
|
||||
">Today marks the beginning of the Summer Olympics! One of the brand-new events this year is [sport climbing](https://olympics.com/tokyo-2020/en/sports/sport-climbing/).\n",
|
||||
">\n",
|
||||
">Suppose the organizers place climbing holds randomly on a 10 meter tall climbing wall until there is a **path**: a series of moves from the bottom to a hold, and then to successive holds, and finally to the top, where each move is no more than 1 meter distance. For the first event, the vertical positions are chosen uniformly at random, and all the holds are aligned at the same horizontal position. On average, how many holds (not including the bottom and top of the wall) have to be placed to make a path?\n",
|
||||
">Suppose the organizers place climbing holds uniformly at randomly on a 10-by-10 meter climbing wall until there is a **path**: a series of moves from the bottom of the wall to a hold, and then to successive holds, and finally to the top of the wall, where each move is no more than 1 meter distance. There are two climbing events:\n",
|
||||
"> - For the first event, all the holds are placed at random heights on a single vertical line. \n",
|
||||
"> - For the second event, holds are placed at random anywhere on the wall. \n",
|
||||
">\n",
|
||||
"> On average, how many holds (not including the bottom and top of the wall) have to be placed to make a path in each event?\n",
|
||||
"\n",
|
||||
"A hold can be represented by a single number, the vertical height off the ground (the horizontal positions are all the same and need not be represented). I'll define `place_holds` to randomly place holds until a path is formed (as detected by `is_path`). Internally to the function, the bottom and top of the wall are considered to be holds, but these are excluded from the output of the function."
|
||||
"# First Event\n",
|
||||
"\n",
|
||||
"A hold can be represented by a single number, the vertical height off the ground. I'll define `place_holds` to randomly place holds until a path is formed (as detected by `is_path`). Internally to the function, the bottom and top of the wall are considered to be holds, but these are excluded from the output of the function."
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -114,8 +120,6 @@
|
||||
"\n",
|
||||
"# Second Event\n",
|
||||
"\n",
|
||||
"> For the second event, holds are placed uniformly at random anywhere on a 10-by-10 meter wall. On average, how many holds have to be placed to make a path?\n",
|
||||
"\n",
|
||||
"For this event a hold is represented by a point in 2-D space: an `(x, y)` tuple of two numbers:"
|
||||
]
|
||||
},
|
||||
@ -580,6 +584,58 @@
|
||||
"source": [
|
||||
"fit(range(2, 26), place_holds_2d, repeat=100);"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Do the Math\n",
|
||||
"\n",
|
||||
"The Monte Carlo approach can only give an approximation. To get an exact result requires a level of math that is above my ability. Fortunately, a real mathematician, [George Hauser](https://www.math.rutgers.edu/component/comprofiler/userprofile/gdh43?Itemid=753), provided the following analysis of the first event:\n",
|
||||
"- If you choose uniformly randomly *n* numbers between 0 and 1 and put them in order (including 0 and 1 in the list) and look at the *n*+1 gaps between them, the probability that any given *k* of the gaps are greater than *x* is (1-*kx*)<sup>*n*</sup> if *kx* ≤ 1 and 0 otherwise. So by inclusion-exclusion, the probability that the largest gap is greater than *x* is the sum of the probabilities that each individual gap is greater than *x*, minus the sum of the probabilities that each pair of gaps are simultaneously greater than *x*, plus the sum of all triples, etc. \n",
|
||||
"- So as a formula it is Pr(*X*<sub>*n*</sub> > *x*) = ∑<sub>*k* ≤ 1/*x*</sub> (-1)<sup>*k*-1</sup> (*n*+1 choose *k*) (1-*kx*)<sup>*n*</sup>.\n",
|
||||
"- Here *X*<sub>*n*</sub> is the largest gap that appears in a sample of *n* random points between 0 and 1. \n",
|
||||
"- What we are interested in is *N*, the first step at which *X*<sub>*n*</sub> < *x*, and E(*N*) the expectation of *N*. \n",
|
||||
"- This expectation is ∑<sub>*n* ≥ 1</sub> *n* Pr(*X*<sub>*n*</sub> < *x* and *X*<sub>*n-1*</sub> > *x*). \n",
|
||||
"- But the sequence *X*<sub>*n*</sub> is decreasing since the biggest gap can only get smaller when you add a new hold. \n",
|
||||
"- So this series just telescopes into ∑<sub>*n* ≥ 1</sub> Pr(*X*<sub>*n*</sub> > *x*).\n",
|
||||
"- So combining the two formulas we need to evaluate ∑<sub>*n* ≥ 1</sub>∑<sub>*k* ≤ 1/*x*</sub> (-1)<sup>*k*-1</sup> (*n*+1 choose *k*) (1-*kx*)<sup>*n*</sup>. \n",
|
||||
"- If you sum first over n, this gives ∑<sub>*k* ≤ 1/*x*</sub> (-1)<sup>*k*-1</sup> (*kx*)<sup>-2</sup> (1/(*kx*)-1)<sup>*k* - 1</sup>. \n",
|
||||
"- I couldn't really simplify this further, but it is easy enough to plug in *x* = 1/10 (i.e. 1 out of 10 meters) and get the answer.\n",
|
||||
"\n",
|
||||
"Hauser did the computation with exact rationals and with floating point approximations:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 42,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"226824785043461849328151/5269256457858371026944 ≅ 43.046829634792914\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from fractions import Fraction\n",
|
||||
"\n",
|
||||
"def hauser(x):\n",
|
||||
" \"\"\"George Hauser's formula for the expected number of holds in the first Event.\"\"\"\n",
|
||||
" return sum((-1) ** (k - 1) * (k * x) ** -2 * (1 / (k * x) - 1) ** (k - 1)\n",
|
||||
" for k in range(1, int(1/x) + 1))\n",
|
||||
"\n",
|
||||
"print(hauser(Fraction(1, 10)), '≅', hauser(1 / 10))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"This agrees well with my Monte Carlo estimate."
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
Loading…
Reference in New Issue
Block a user