- #1
- 1,120
- 1
Knowing I did mathematics my room mate posed me a question yesterday, he wanted to know given a number of tracks randomly played what is the average of a track being first repeated. He'd already written a program in Perl to solve this problem by brute calculation but was coming up with some very odd answers, he later discovered the random function wasn't very good.
Now, I was some what rusty on my probability skills and had to take this away to think about it. This did and still does sound like a very doable problem. This is how I started out:
Let X be the track number where the first repeat is, where the initial track played is track 0. Let x1 be the event where X=1, x2 be the event where X=2 etc.. To start off easy, let there be 3 tracks, then:
[tex]P(x_1) = \frac{1}{3}[/tex]
It follows then that:
[tex]P(x_2 | {x_1}') = \frac{2}{3}[/tex]
(In words, the probability of x2 occurring given that x1 has not occurred is 2/3). It therefore follows from some basic rules of probability:
[tex]\frac{P({x_1}' \cap x_2)}{P({x_1}')} = \frac{2}{3}[/tex]
I then drew a little diagram to show that x2 was a subset of x1'. And therefore:
[tex]P(x_2) = \frac{4}{9}[/tex]
I then worked out the probability of x3 the long way to make sure I was doing everything right, by saying that:
[tex]P(x_3|({x_2}' \cap {x_1}')) = 1[/tex]
After expanding and reducing this nicely led to:
[tex]P(x_3) = \frac{2}{9}[/tex].
This gave a nice expectation of x as:
[tex]E(x) = \frac{17}{9}[/tex]
I then set out looking at n tracks, which was pretty much the same:
[tex]P(x_1) = \frac{1}{n}[/tex]
[tex]P(x_2 | {x_1}') = \frac{2}{n}[/tex]
Which led to:
[tex]P(x_2) = \frac{2}{n} - \frac{2}{n^2}[/tex]
I also worked out:
[tex]P(x_i | ( {x_{i-1}}' \cap \ldots \cap {x_1}')) = \frac{P(x_i)}{P({x_{i-1}}' \cap \ldots \cap {x_1}')}[/tex]
Which leads to:
[tex]P(x_i) = \frac{i}{n} \left(1 - \sum_{r=1}^{i-1} (P(x_r)) \right) \quad \text{with} \quad P(x_1) = \frac{1}{n}[/tex]
This is far too complicated for me to deal with, so I attempted to put into mathematica and it doesn't seem to be able to make anymore out of it that I can either. I feel I am going wrong somewhere because this doesn't seem like too difficult of a problem.
Now, I was some what rusty on my probability skills and had to take this away to think about it. This did and still does sound like a very doable problem. This is how I started out:
Let X be the track number where the first repeat is, where the initial track played is track 0. Let x1 be the event where X=1, x2 be the event where X=2 etc.. To start off easy, let there be 3 tracks, then:
[tex]P(x_1) = \frac{1}{3}[/tex]
It follows then that:
[tex]P(x_2 | {x_1}') = \frac{2}{3}[/tex]
(In words, the probability of x2 occurring given that x1 has not occurred is 2/3). It therefore follows from some basic rules of probability:
[tex]\frac{P({x_1}' \cap x_2)}{P({x_1}')} = \frac{2}{3}[/tex]
I then drew a little diagram to show that x2 was a subset of x1'. And therefore:
[tex]P(x_2) = \frac{4}{9}[/tex]
I then worked out the probability of x3 the long way to make sure I was doing everything right, by saying that:
[tex]P(x_3|({x_2}' \cap {x_1}')) = 1[/tex]
After expanding and reducing this nicely led to:
[tex]P(x_3) = \frac{2}{9}[/tex].
This gave a nice expectation of x as:
[tex]E(x) = \frac{17}{9}[/tex]
I then set out looking at n tracks, which was pretty much the same:
[tex]P(x_1) = \frac{1}{n}[/tex]
[tex]P(x_2 | {x_1}') = \frac{2}{n}[/tex]
Which led to:
[tex]P(x_2) = \frac{2}{n} - \frac{2}{n^2}[/tex]
I also worked out:
[tex]P(x_i | ( {x_{i-1}}' \cap \ldots \cap {x_1}')) = \frac{P(x_i)}{P({x_{i-1}}' \cap \ldots \cap {x_1}')}[/tex]
Which leads to:
[tex]P(x_i) = \frac{i}{n} \left(1 - \sum_{r=1}^{i-1} (P(x_r)) \right) \quad \text{with} \quad P(x_1) = \frac{1}{n}[/tex]
This is far too complicated for me to deal with, so I attempted to put into mathematica and it doesn't seem to be able to make anymore out of it that I can either. I feel I am going wrong somewhere because this doesn't seem like too difficult of a problem.