1. Question: What is the probabilty that the sequence of digits 123 will appear in a nine digit long sequence.

To clarify: If you have some randomly generated nine digit sequence like 918273645, then what is the probability that the 123, will appear. (the digits 123 have to be consecutive)

I have thought about this problem for a while now, and it has proven to be more difficult than I initially thought.

This is what I have thought so far. First, one must see how many sets of three consecutive digits appear in the sequence. In the case of a nine digit sequence then there are 7 such sets.
102, 028, 285, 856, 562, 628, 285

The chances that the string 123 matches with one of these sets is

My logic seems solid up to this point and then things get shaky.

Since we are given 7 sets then our chances that at least one matches is ??? BUT, I'm sure that must be wrong, because by that logic if we are given sets, then our probability would be one, and obviously it should always be less than one.

I am stuck. (I have some other ideas about how to approach it but I'll see what you guys have to say first,,, surely the solution must not be too complicated)

2.

3. Wait, maybe its this

You take 1 MINUS (the probability that the set won't match a given set, raised to the power of the number of sets)

The probability that our 123 won't match a given set of 3 digits is

There were 7 sets, and is roughly

So is roughly

So thats our answer, the probability that the 123 will appear is roughly

I think this method might work because I just checked it for finding a one digit long sequence in another one digit long sequence. Obviously the chances of this would be .1, and my method yields .1

Is this correct?

4. First you calculate the probability 1 appear in one of the first 7 digits, and multiply that with the probability 2 appears after it, and the probability 3 appears after that.

Probability 1 appear in one of the first 7 digits
=1-probablity that 1 doesn't appear.

Multiply that by probability 2 appears in the digit after 1(1/10), and the probability 3 appears after 2(1/10).

=0.00527608

5. My result did not include numbers that start with 0 or 0s. I noticed that you did. To get the probability between 000000000 and 999999999, you replace all the s with s and the 9000000s with 10000000.
The result should be

6. it's simple. there are 10^6 different ways that 123 appear in the first three digits of a nine digit sequence. examine: 123000001, 123000001, so on and so forth to 123999999. for a total of 1,000,000 ways for it to occur. similarly there are a million ways for it to occur in digits 2-4. then the same for digits 3-5. so on and so forth till you get to digits 7-9. that means there are seven positions 123 can be found in seven different places. each with one million ways of occuring for a total of 7,000,000 ways for you to find that combination. a propability is expressed as positive events over total events. so that is seven million over your total.

to calculate the total you take the different values for each digit(there are ten) and you raise that number to the number of digits(you stated there are nine digits) so that is 10^9. your answer is (7*10^6)/10^9 which is more simply expressed as .0007

7. You're double counting a lot of those 7,000,000 (for example 123123123 gets counted 3 times by that method).

8. number of possible outcomes: or if sequences starting with are banned.

number of possible outcomes where are grouped at least once:

number of possible outcomes where are grouped at least twice:

number of possible outcomes where are grouped three times: .

at least once - at least twice + three times =

probability is

Did I get it right?

edit: nope, but almost - got a sign fault which is corrected now.

9. Yep, that was a dumb moment... I added a phantom digit for no reason but to show myself a fool.

10. Hmm, I didn't do this on paper so I am aware the risk of making a fault would be high. I got that through the numbers of ways to arrange 2 groups of and 3 groups of and then multiplying with possible values of .

How did you get ?

11. Probabilty of first digit 1 = 10-1
Second 2 = 10-1
third 3 = 10-1

=1000-1 = 0.001

If it is no that, which is won't be 999/100 of the time then you have another 1000-1 shot.

Note I am doing this for 4 digits to make it easy.

So for four digits it is 1/1000 + 999/1000 x 1/1000 = 0.0019990 (4)

If it doesn't occur then which it wont 1 - 0.0019990 = 0.9980010 of the time
you get anther 1/1000 shot = 0.9980010 x 0.001 = 0.0009980

So add that to (4) = 0.0029970

Next one is 1 - 0.0029970 = 0.9970030 x 0.001 = 0.0039940 (5)

I think if you repeat that you get the answer eventually.

Does that tally with anyone else's results?

Can I make an easy formula?

Or 7 x 0.001 x 0.999^6= 0.006958104860104958007

12. Well yes I can but it is wrong, because that is the chance of occuring only once!!

Maybe the first method works?

I give up for now!!

I think the first method works but it is labour intensive and I am tired,
I will see if it is the same as other answers when I do work it all out.

13. Another method.

It could occur 7 times once = 0.001^7
It could occur 6 times 7 ways = 7 x 0.001^6
It could occur 5 times 21 way = 21 x 0.001^5
It could occur 4 times 35 way = 35 x 0.001^4
It could occur 3 times 35 way = 35 x 0.001^3
It could occur 2 times 21 way = 21 x 0.001^2
It could occur 1 times 7 ways = 7 x 0.001

That answer might tally with another method, proving both are right!!

(or both are wrong )

I think this is the way to go as I have seen my previous method get the same answer
as this kind of method on poker probability questions (IIRC).

Nice question either way.

Please note I have made a massive error I think as I missed off all the 0.999's and the powers to ensure it only occured the specified number of times

eg 21 x 0.001^5 x 0.999^2.

There is a probability I have made other errors (at a guess 9999999-10000000)

14. Ok, let me see if I can't take a clearer shot at this. For any problem like this, there are always multiple ways it can be done, but they should always give the same answer.

To be able to sum up parts, the parts need to be mutually exclusive, so with that in mind, each * is any digit, and each ? is any digit that doesn't make a 123.
- 123****** (1000000 possibilities)
- ?123***** (10 * 100000 possibilities)
- ??123**** (100 * 10000)
- ???123*** ([1000 - 1] * 1000)
- ????123** ([10000 - 20] * 100)
- ?????123* ([100000 - 300] * 10)
- ??????123 (1000000 - 3999)
Total: 6,990,001 (out of 1,000,000,000)

Now to double check that, let's try a different way. Let's ask how many ways 123 could show up in an n-digit sequence. Let's call this C(n).
- Obviously C(1) and C(2) = 0 and C(3) = 1
- For C(n), the number of ways it can show up at digit k is the number of ways you can arrange the digits before k to not have a 123 times the number of ways to rearrange the digits after k, which gives (10^k - C(k))*(10^(n-3-k)). Then C(n) is the sum over k from 0 to n-3.
- Then, plugging that into a spreadsheet gives:
- C(4) = 20
- C(5) = 300
- C(6) = 3999
- C(7) = 49970
- C(8) = 599400
- C(9) = 6990001 (Same as above)

(Note that this second way may be too similar to the first to make for a really solid double check. jakotako's method works pretty well, but you need to add the triples back after having subtracted them out in the doubles already.)

15. Originally Posted by MagiMaster
(Note that this second way may be too similar to the first to make for a really solid double check. jakotako's method works pretty well, but you need to add the triples back after having subtracted them out in the doubles already.)
Ah, right. Missed that 7000000 was the sum of the number of elements in the three sets used in the inclusion/exclusion principle. (that sentence make little sense I know)

Anyway, that means or results match. I'll fix that sign difference to so I don't fool someone. Thanks!

Agreed on out of

16. When I have a bit more time I will write a computer simulation which will be
a way hopefully of verifying the solution.

Problem is it might take a long time to get the required accuracy.

17. Lets look at this again

It could occur 7 times once = 0.001^7 x =0.000000000000000000001
It could occur 6 times 7 ways = 7 x 0.001^6 x 0.999 = 0.000000000000000006993
It could occur 5 times 21 way = 21 x 0.001^5 x 0.999^2 = 0.000000000000020958021
It could occur 4 times 35 way = 35 x 0.001^4 x 0.999^3 = 0.000000000034895104965
It could occur 3 times 35 way = 35 x 0.001^3 x 0.999^4 0.000000034860209860035
It could occur 2 times 21 way = 21 x 0.001^2 x 0.999^5 = 0.000020895209790104979
It could occur 1 times 7 ways = 7 x 0.001 x 0.999^6 = 0.006958104860104958007

And finally it could not occur at all 0.999^7= 0.993020965034979006999

Grand total 0.00699993017481109798

And finally it could not occur at all 0.999^7= 0.993020965034979006999

Giving a total of 1.000020895209790104979 which is over 1 which is obviously wrong.

However note the bit after the decimal point 00020895209790104979 is the same as the occur 2 times 21 way = 21 x 0.001^2 x 0.999^5 = 0.000020895209790104979

So maybe I added that up twice?

However I get the answer by finding when it will not occur which was
0.993020965034979006999
and taking that from 1 to give 0.006979034965020993001

It was only when I got to the last bit of finding when it would not occur at all that I realised that I had made a lot of work for myself.

However I think if I add up all my probabilities they will add up to 1.000 I think, I just seem to have have added one term twice.

 infact I did add it twice, if you add them correctly all the values add up and equal 1 exactly.

It was only when I wanted to check it all added to one 1 realised I could have saved myself a lot of work, however it was an interesting exercise to be able to do it the 'long way'.
That shows I have all the separate probabilities of each possible outcome and they all add up to 1 as they should which is a good check to ensure you have not made a mistake anywhere.

18. Originally Posted by SteveC
Wait, maybe its this

You take 1 MINUS (the probability that the set won't match a given set, raised to the power of the number of sets)

The probability that our 123 won't match a given set of 3 digits is

There were 7 sets, and is roughly

So is roughly

So thats our answer, the probability that the 123 will appear is roughly

I think this method might work because I just checked it for finding a one digit long sequence in another one digit long sequence. Obviously the chances of this would be .1, and my method yields .1

Is this correct?

Yes it does seem to be correct, I mean I went through calculating all the probabilities or there being one occurrence of 123 up to 7 occurrence to get the answer, then it was blindly obvious that 1 minus all that lot was the probability of no occurrences!
So basically I covered every possibility and they all add up to 1 as they should.

It is a bit unnatural to do it your way as that is not normally how you would approach the problem, but it is certainly the easiest method.

A case of not seeing the woods for the trees!

 Bookmarks
##### Bookmarks
 Posting Permissions
 You may not post new threads You may not post replies You may not post attachments You may not edit your posts   BB code is On Smilies are On [IMG] code is On [VIDEO] code is On HTML code is Off Trackbacks are Off Pingbacks are Off Refbacks are On Terms of Use Agreement