Ask your own question, for FREE!
Mathematics 7 Online
OpenStudy (anonymous):

Say we flip a fair coin n (for example n=100) times. How would one calculate the expected value of how many time a sequence occurs (for example HHT where H:heads, T:tails)?

OpenStudy (anonymous):

Can't figure this problem out other than that it would be the same for any sequence that the expected value would be: \[n\times \frac{1}{2^3}\]

OpenStudy (anonymous):

How did you get 98? How would that change if the sequence was for example HHH?

OpenStudy (dan815):

i have a few other ideas to try so i ask

OpenStudy (anonymous):

I understand your solution but It's a part of a problem problem involving Penney's game which I know isn't a fair game thus I would expect different expectations for different sequences?

OpenStudy (anonymous):

or is it only when comparing relative probabilities of different sequences one would find different probabilities/expectations for different sequences?

OpenStudy (anonymous):

dan i was thinking maybe usin combinations or permutations not too sure tho

OpenStudy (dan815):

thats hwat i mean

OpenStudy (dan815):

for example you look at the first 3 in the 100 flips, are you allowed then look at the next 3 starting from the 2nd one, and say that is also 1/8 , i dont think u can because it is included when you checked the first 3

OpenStudy (dan815):

my other method was

OpenStudy (dan815):

lets check 3 at a time differently

OpenStudy (dan815):

sigh maybe i shouldht have deleted that stuff, it doesnt seem wrong

OpenStudy (dan815):

oh nvm it is wrong!

OpenStudy (dan815):

i see what u mean if they are all HH you can have a chance of 98 sequences but there is no way to have more than a sequence of 33 hot HHT

OpenStudy (dan815):

do you know what hte right answer is?

OpenStudy (anonymous):

Unfortunately there are no answers to the questions but I can ask my professor next week. I really appreciate you taking the time to discuss my question, thank you.

OpenStudy (dan815):

wait lol

OpenStudy (dan815):

I actually can get the right answer

OpenStudy (dan815):

we can work backwards

OpenStudy (dan815):

iam writing a program for it right now

OpenStudy (anonymous):

oh, cool, what do you mean with working backwards?

OpenStudy (dan815):

like see what the probability really is

OpenStudy (dan815):

and then we can try some ideas and see which one is actually giving us the right answer

OpenStudy (dan815):

okay done!

OpenStudy (anonymous):

ok

OpenStudy (anonymous):

nice :)

OpenStudy (dan815):

i will run it for 100 times

OpenStudy (dan815):

100 times

OpenStudy (dan815):

and see what hte average is

OpenStudy (dan815):

then we will see for 1000 flips and avg that over 100 times

OpenStudy (anonymous):

ok, interesting

OpenStudy (dan815):

okay i got

OpenStudy (dan815):

avgc() 11.83 >>> avgc() 11.87 >>> avgc() 11.88 >>> avgc() 11.78 >>> avgc() 12.15

OpenStudy (dan815):

avg 12.23

OpenStudy (dan815):

always hobering around 12

OpenStudy (dan815):

12 HHT for 100 flips

OpenStudy (dan815):

lets see if the ratio remains for 1000 flips

OpenStudy (dan815):

avgc() 124.833 >>> avgc() 124.711 >>> avgc() 124.499

OpenStudy (dan815):

the 1000 one is a lot more accurate

OpenStudy (dan815):

always hovering around 124.5

OpenStudy (dan815):

so for 100 we should be getting something like 12.45

OpenStudy (dan815):

avgc() 124.833 >>> avgc() 124.711 >>> avgc() 124.499 >>> avgc() 124.507 >>> avgc() 124.546 >>> avgc() 124.719 >>> avgc() 124.792

OpenStudy (dan815):

yep

OpenStudy (anonymous):

ok, is it the same result for other sequences?

OpenStudy (dan815):

nope

OpenStudy (dan815):

what sequence you want to try ?

OpenStudy (dan815):

do you know how to use python

OpenStudy (anonymous):

Somewhat, had an introductory course to programming in python.

OpenStudy (anonymous):

for example HHH

OpenStudy (dan815):

i did avg of the 100 range 100 times and it is always 12.1 ish

OpenStudy (dan815):

here is my code

OpenStudy (dan815):

on the 9th line you can change it any sequence you want

OpenStudy (dan815):

as long as its length 3

OpenStudy (dan815):

i will try HHH

OpenStudy (anonymous):

Thank you, I'll try it

OpenStudy (dan815):

oh its actually the same for HHH :O

OpenStudy (dan815):

samething for htt

OpenStudy (dan815):

12.1 to 12.15 ish

OpenStudy (dan815):

you can improve the accuracy if you tweak final part of the code

OpenStudy (dan815):

if you make the last part range 1000 and divided by 1000

OpenStudy (dan815):

but it might slightly lagg your computer

OpenStudy (anonymous):

ok, i'll try it. Thanks for the program! What led me to believe that the expectation was different was the analysis in this wikipedia article: http://en.wikipedia.org/wiki/Penney's_game#Analysis_of_the_three-bit_game

OpenStudy (dan815):

wait a second let me check my code!!

OpenStudy (dan815):

it looks right

OpenStudy (dan815):

the brute force method cant be that off -_- unless i made some mistake in code let me check again

OpenStudy (dan815):

from random import* def check(a): x=['h','t'] slist=[] for i in range(a): slist.append(x[randint(0,1)]) count = 0 for i in range(len(slist)-2): if slist[i:i+3]==['h','h','t']: count=count+1 return count def avgc(): sum2=0 for i in range(100): sum2=sum2+check(100) avg=sum2/100.0 return avg sum1=0 for i in range(100): sum1+=avgc() avg2=sum1/100.0 print avg2

OpenStudy (dan815):

i fixed a mistake, but its pretty much the same thing

OpenStudy (dan815):

12.25* is your avg answer

OpenStudy (dan815):

for HHH and HTT and HHT

OpenStudy (anonymous):

I read a document discussing how to find the probability of a "triplet" (for the diagram se attached file): "It is clear from the figures that one can arrive at either goal state by many different paths involving many different numbers of steps. To find the expected number of tosses for any given triplet, one could multiply the length of every unique path to that triplet with its probability of occurrence and take the sum of products over all unique paths".

OpenStudy (dan815):

@kingGeorge

OpenStudy (dan815):

i keep getting 12.25 for all the possible sequence of 3

OpenStudy (dan815):

maybe that wikipedia article is saying

OpenStudy (kinggeorge):

The way I would approach finding the expected value of HHT, is to find the total number of length 3 sequences, and then multiply by the probability of getting HHT, or 1/8. So if you flip the coin 100 times, there are 98 total sequences of length 3. So the expected value would be 98/8=12.25.

OpenStudy (dan815):

if you consider the choices like one guy picks HHH and the other guy picks HHT then for that game, there is a difference chance of winning

OpenStudy (dan815):

that is what i thought the first time around too

OpenStudy (dan815):

but he said this wikipedia article had something else to say about it http://en.wikipedia.org/wiki/Penney's_game#Analysis_of_the_three-bit_game

OpenStudy (dan815):

i think that wikipedia article is saying something different that is how to win, based on the opponents choice or something

OpenStudy (kinggeorge):

The game is completely different than what we want to solve. Penney's game is asking for the probability that a certain sequence occurs \(first\). The problem we're given has a fixed number of coin flips.

OpenStudy (dan815):

ya for example if u pick HHH and I pick THH then my 2HHs after i get a T can result from 2 of your waits so i have a chance of finishing faster

OpenStudy (dan815):

"An intuitive explanation for this result, is that in any case that the sequence is not immediately the first player's choice, the chances for the first player getting their sequence-beginning, the opening two choices, are usually the chance that the second player will be getting their full sequence. So the second player will most likely "finish before" the first player.[2]"

OpenStudy (anonymous):

ok, I understand, thank you for taking time to answer my question, really appreciate it!

OpenStudy (dan815):

the probabililty you see for the HHH and THH will be the same but which one is faster is different

OpenStudy (dan815):

u want a program for this too xD

OpenStudy (kinggeorge):

These nontransitive games are weird to think about for me. But the way I see it, every sequence is equally likely to show up at some point, but some are more likely to occur before certain other sequences. To get the nontransitivity bit, it requires you to choose two sequences in a certain order, but when we're talking about expected value, we only choose a single sequence.

OpenStudy (dan815):

or you can try fiddling around with that program yourself its pretty easy to implement it

OpenStudy (dan815):

you set up 2 counters for each game and award victory to the first sequence completed and repeat this process see the prob of win over 100 times and so on

OpenStudy (anonymous):

yes, I can try it on my own, good exercise in python as well :) Thanks again!

OpenStudy (dan815):

sure !! see ya around

OpenStudy (anonymous):

see ya :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!