# Probability of a run of 'heads'

Discussion in 'Mathematics' started by ColinWilson, Mar 26, 2011.

1. ### ColinWilson

I arrived at the same solution but as you said the logic is flawed. Your answer represents the expected number of 7 head runs in 100 spins. A run of 8 heads or two 7 heads runs would be double counted, a run of 9 is triple counted etc. Hence with 6 head runs you get an answer over 1.
Colin

2. ### bbibblerNew commenter

Thank Colin.

My next problem is that my VB simulation is not getting anywhere near the theoretical answer. I think it is time to give up.

3. ### scentless_apprentice

Why not?
People here are of able enough intelligence to understand them.

5. ### GoldMathsNew commenter

Works perfectly really nice simulation thanks!

6. ### weebecka

It didn't run for me but I like the design is elegant. I like it.

7. ### AnotherMathsHoD

What version of Excel are you running (I used the randbetween function, and I can't remember when that got moved from being an add-in to the core). Also make sure you have macros enabled otherwise the button wont work...

8. ### ian60New commenter

I loved the way you were able to keep a count of the number of heads, I find I always miss those creative steps. (Maybe it is blindingly obvious to everyone else, but I was impressed)
Am I right in thinking your simulation will count a run of 8 as two runs of 7 and a run of 8?
I enjoyed playing with it, and am grateful to you for putting it out there.

9. ### AnotherMathsHoD

The simulation only checks the length of the longest run, and counts it singularly. So a run of 8 is counted as a run of "7 or more". I was really pleased with the way it kept track of the number of Heads in a run. I had tried a few much more complicated approaches before I hit on this solution!
Thank you for raising such an interesting question, I knew nothing about Markov Chains (beyond the word!) beforehand...

10. ### AnotherMathsHoD

Just for fun I've generalised it so you can change the number of coins, the maximum run of Heads you are looking for and the number of trials... You can have up to 10,000 coins (but obviously it will get slower the more you use!!)
I did a little digging and the Randbetween function wasn't brought into the core functionality of Excel until 2007, so if you are running Excel 2003 you will need to add it in...
These are the instructions from the MS Office website:
In the Add-Ins available list, select the Analysis ToolPak box, and then click OK.
If necessary, follow the instructions in the setup program.

11. ### pipipi

Very well done AMH. Glad to see a useful contribution alongside my spam!

Is there a course on how to write Excel things like this? Or is it just stuff from computing courses applied to excel.
(I just find myself admiring the view and knowing that I couldn't reproduce if it I tried. Perhaps I shouldn't try..)

12. ### AnotherMathsHoD

I guess there must be courses out there but I'm self taught... I've dabbled in programming on and off over the last 20years. I always find the best way to do VBA is to use the 'Record Macro' option then do roughly what you want to happen... Then look at the code it has produced and play with it until it works how you want it to!

There are also a lot of decent tutorials on YouTube that you could watch - try something like:

Good luck!

13. ### ian60New commenter

Being the OP, I thank you for your consideration.
I am, indeed, one of those posters who "could (not) go there rapidly without needing scaffolding"
However, I ought to add none of your responses helped me scaffold anything apart from an incorrect view of the problem as a whole.
Thank you for your responses, but I think you might be telling a few porkies if you claim that you understood the correct approach from the start.

14. ### weebecka

AMH I've recently changed from Excel 2003 to Excel 2007 (PC) and I can't find how to add in the analysis toolkit so the macro won't run. I think the instructions you gave work for Excel 2003. Help seems to be missing too. =(.
Enough for me for today I think but it does look good.

Pipipi there a lady called Sydney Tyrell who runs all sorts of courses on Excel. Creating things like this isn't hard IF you've got someone to show you how but it's really frustrating to try and puzzle out with no help.
She also does excel worshops on pivot tables and other topics. I find pivot tables really useful.
She runs sessions at most major conferences and she teaches at Douglas Butler's TSM courses as well.
http://www.tsm-resources.com/
so you can combine a workshop on this with some other things if you want.

Anyone know any good online teach yourself courses on this kind of Excel workbook?

15. ### ian60New commenter

Priceless!
Mi casa, tu casa.

16. ### pipipi

I think I might be better off sending AMH a few beers and asking nicely, much more successful than me trying to get my head round that on a Sunday. But that could be th alcohol in Pipipi version 2011.

17. ### weebecka

Okay point taken.
? In the 2 mins I had to think about the problem when I tried (and obviously failed) to point out why it was non-trivial I was picturing thinking along the lines of Markov chains. Did I completely solve it in that time? Of course not. It takes longer than that. Did I claim to? No. Quite the opposite.
I'm sorry you got lost. It's hard to communicate complex maths ideas through posts.

I'm not quite sure why I deserve quite so much criticism. Others made incorrect posts. I was only trying to explain why it was non-trivial because the previous posters throught it was. Yes I made an error in a formula just because I was in such a rush. But blimey - if a post doesn't make sense just say so and leave it for the poster to sort it out. Or as everyone did with the other incorrect posts on this thread, er, just ignore them.

18. ### pipipi

methinks the poster doth protest too much

19. ### Colleen_YoungOccasional commenter

AnotherMathsHoD - thank you. Used files with no problems Excel 2007 (PC).
All worked very nicely.

20. ### AnotherMathsHoD

You are right the instruction I gave are for Excel 2003 as all the functions should work in Excel 2007, so you shouldn't need to do anything other than agree to allow the macro to run... What is the error message you are getting?