# Analyzing a probability problem

**URL:** <https://boards.straightdope.com/t/analyzing-a-probability-problem/33664>\
**Category:** Factual Questions\
**Created:** [September 18, 2000, 10:49pm UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664 "2000-09-18T22:49:35Z")\
**Posts on this page:** 11\
**Page:** 2

<div class="post-metadata">

**Author:** ![RickG](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/rickg/32/5174_2.png) [@RickG](https://boards.straightdope.com/u/RickG)\
**Post date:** [September 19, 2000, 9:38pm UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664/21 "2000-09-19T21:38:13Z")

</div>

**panamajack** , I think **APB9999** is actually pretty much correct about the continuous case, with **kesagirl** ’s slight amendment. Before I looked at his solution, I worked it out myself. Let me try to explain the approach I took.

Let p(x) be the probability of finding a parking space at x.  
Let P(x) be the probability that the car ends up parking at x. By definition, the car parks at the first empty space, so P(x) is also the probability that the car couldn’t find a spot closer than x times the probability that there is a space at x (which is p(x)). So, using the two definitions for P(x), we have the equation

P(x) = p(x) \* (1 - int[sub]0-\>x[/sub]P(y)dy)

This is an integral equation for P(x), given the distribution p(x). Your objection that the discrete case involves products, so there shouldn’t be an integral is incorrect. The way you set up the discrete case, the products involved p, not P.

Fortunately, we can reduce this to a differential equation fairly easily. Take the derivative with respect to x to get

P’ = p’ \* (1-int[sub]0-\>x[/sub]P(y)dy) - p(x)\*P(x)

and note that the term multiplying p’ is just P/p (from the first equation). Incidentally, the last term comes from the Fundamental Theorem of Calculus, that the derivative of the integral of a function is just the function. So,

P’ = ((p’/p) - p)P

If you know p(x), you can solve this ODE given the following boundary conditions:

1. P(0) = 0
2. Integral of P over all x = 1.
3. If p(x) is not differentiable everywhere, you may need to impose continuity conditions on P as well.

How’s that?

Rick

---

<div class="post-metadata">

**Author:** ![RickG](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/rickg/32/5174_2.png) [@RickG](https://boards.straightdope.com/u/RickG)\
**Post date:** [September 19, 2000, 9:47pm UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664/22 "2000-09-19T21:47:23Z")

</div>

Oops, minor screw-up. My boundary condition 1 should be P(0)=p(0) (from the first equation). I had worked out the result for the sample case where p(x) is linearly increasing from 0 to 1 out to some distance x[sub]0[/sub], after which it is 1. In that case p(0) _is_ 0 (and, thus, so is P(0)), but that’s a special case.

Rick

---

<div class="post-metadata">

**Author:** ![panamajack](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@panamajack](https://boards.straightdope.com/u/panamajack)\
**Post date:** [September 19, 2000, 10:39pm UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664/23 "2000-09-19T22:39:28Z")

</div>

Wow Rick, you win! That’s exactly the sort of thing I was hoping for. Didn’t even think of that approach.

BTW, APB9999 did label his equation incorrect (assuming he was doing the same as you did); he had f(x) inside the integral, which of course doesn’t work out, hence my objection.

again, thank you very much.

And apologies to kesagiri; turns out the c.d.f. was indeed an important part of the solution

panama jack

---

<div class="post-metadata">

**Author:** ![kesagiri](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kesagiri](https://boards.straightdope.com/u/kesagiri)\
**Post date:** [September 19, 2000, 10:48pm UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664/24 "2000-09-19T22:48:29Z")

</div>

Hey no problem, I am embarassed it took me so long to see what your question was…:o

---

<div class="post-metadata">

**Author:** ![RickG](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/rickg/32/5174_2.png) [@RickG](https://boards.straightdope.com/u/RickG)\
**Post date:** [September 19, 2000, 10:54pm UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664/25 "2000-09-19T22:54:04Z")

</div>

> [@](#):
>
> \*Originally posted by panamajack \*  
> **Wow Rick, you win!**

Woohoo!! Are there fabulous prizes?

Cheers,  
Rick

---

<div class="post-metadata">

**Author:** ![APB9999](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@APB9999](https://boards.straightdope.com/u/APB9999)\
**Post date:** [September 25, 2000, 11:38pm UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664/26 "2000-09-25T23:38:06Z")

</div>

Yup, all the corrections are right. It is of course true that int[sub]0-\>x[/sub][1-f(x)] = 1-int[sub]0-\>x[/sub][f(x)]; here I was just keeping concepts together in the expression, and 1-f(x) has a clear intuitive interpretation. This doesn’t really affect the outcome, though.

More seriously, I did goof, as Rick points out, in using (in my notation) f(x) rather than p(x). D’OH! That makes solving it a little trickier, where you have to use DEs as Rick explains. He takes the gold!

---

<div class="post-metadata">

**Author:** ![kesagiri](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kesagiri](https://boards.straightdope.com/u/kesagiri)\
**Post date:** [September 26, 2000, 12:26am UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664/27 "2000-09-26T00:26:44Z")

</div>

> [@](#):
>
> \*Originally posted by APB9999 \*  
> **Yup, all the corrections are right. It is of course true that int[sub]0-\>x[/sub][1-f(x)] = 1-int[sub]0-\>x[/sub][f(x)]; here I was just keeping concepts together in the expression, and 1-f(x) has a clear intuitive interpretation. This doesn’t really affect the outcome, though.**

Is that true though? Isn’t

int[sub]0-\>x[/sub][1-f(x)] = x - F(x)?

---

<div class="post-metadata">

**Author:** ![APB9999](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@APB9999](https://boards.straightdope.com/u/APB9999)\
**Post date:** [September 26, 2000, 12:36am UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664/28 "2000-09-26T00:36:05Z")

</div>

Yes, kesagiri, it is. I was going by what you had said earlier, when you made the very mistake you’re catching me in now, and wasn’t watching closely enough. So I was right to keep it simple in the first place, since I’m obviously easily confused. Again, it doesn’t change the analysis, just the manipulations.

---

<div class="post-metadata">

**Author:** ![APB9999](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@APB9999](https://boards.straightdope.com/u/APB9999)\
**Post date:** [September 26, 2000, 12:39am UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664/29 "2000-09-26T00:39:34Z")

</div>

No, I take that back. You didn’t misdo the integration ealier, I mistook your meaning.

---

<div class="post-metadata">

**Author:** ![APB9999](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@APB9999](https://boards.straightdope.com/u/APB9999)\
**Post date:** [September 26, 2000, 12:42am UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664/30 "2000-09-26T00:42:05Z")

</div>

Yes, now I see. I’m a little tired, as you might guess - sorry. Yes, k, you were right from the outset. It should be 1-int[sub]0-\>x[/sub]f(x)dx.

---

<div class="post-metadata">

**Author:** ![kesagiri](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kesagiri](https://boards.straightdope.com/u/kesagiri)\
**Post date:** [September 26, 2000, 4:17pm UTC](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664/31 "2000-09-26T16:17:45Z")

</div>

That’s okay, when looking at integrals in this kind of format making mistakes is easy. First time I looked at yours I was confused too. Hopefully someday will come when we can use the real integral sign…and other mathematical notation on a bulletin board.

Yeah…I know…I’m a geek. 🙂

[Previous page](https://boards.straightdope.com/t/analyzing-a-probability-problem/33664.md?page=1)
