Two Plus Two Poker Forums Coin flips question
 Register FAQ Search Today's Posts Mark Forums Read TwoPlusTwo.com

 Notices

 Probability Discussions of probability theory

 10-01-2018, 07:00 PM #1 wait grinder   Join Date: Oct 2017 Posts: 639 Coin flips question Friend asked me this. Hope it makes sense. If 100 people flip a coin once a day for a year, what percentage can be expected to have a wider spread than 52.38/47.62 heads/tails ratio?
10-01-2018, 08:19 PM   #2
mkind0516
Carpal \'Tunnel

Join Date: Aug 2006
Location: And the home...of the...JETS
Posts: 6,266
Re: Coin flips question

Quote:
 Originally Posted by wait Friend asked me this. Hope it makes sense. If 100 people flip a coin once a day for a year, what percentage can be expected to have a wider spread than 52.38/47.62 heads/tails ratio?
I did a quick simulation of your question (written in R and the code is below in case any users wanted to play around with parameters). I had a person flip a coin 365 times, calculated the absolute difference of heads and tails, and then counted how many reached the threshold you asked for (which came out to a difference 17.374. So a success is any trial where the person flipped at least 17.37 more of one than the other). I repeated this 20,000 times.

The probability of one person getting a difference of at least 52.38% on one outcome or the other was about 34.06%. Since coin flips are all independent, that would mean that on average 34 out of 100 people would hit the threshold.

Here's a histogram of the difference in all 20,000 sims (red line is >= 52.38%):

Code:
```#Number of days a coin is flipped
days.sample = 365

#Calculating what the difference in heads from tails would need to be to hit the threshold

#Simulation trials
n.trials = 20000

#initialize results vector for ratio of heads to tails
ratios = c()

for(trial in 1:n.trials){
#In every trial, a person flips a coin days.sample days in a row. The loop stores the number of heads and tails in the sample and then repeats

tails=c()

for(day in 1:days.sample){

#flip coin
coin = sample(0:1,1)

if(coin == 1){
tails[day] = 0

} else{
tails[day] = 1
}

}
}

#Number of successes in sample
successes = sum(ratios >= ratio.target)

#Likelihood of a person reaching the difference threshhold of heads from tails
successes / n.trials

ggplot(data.frame(ratios), aes(x=ratios)) + geom_histogram() + geom_vline(xintercept = ratio.target, col="red")```

Last edited by mkind0516; 10-01-2018 at 08:25 PM.

 10-01-2018, 08:27 PM #3 heehaww Pooh-Bah     Join Date: Aug 2011 Location: Tacooos!!!! Posts: 4,462 Re: Coin flips question [Sum of C(365, k) from k=192 to k=365] / 2^365 ≈ 17.3% Or twice that if it can also be .5238 tails to heads.
 10-01-2018, 08:29 PM #4 wait grinder   Join Date: Oct 2017 Posts: 639 Re: Coin flips question Thanks
10-01-2018, 08:32 PM   #5
mkind0516
Carpal \'Tunnel

Join Date: Aug 2006
Location: And the home...of the...JETS
Posts: 6,266
Re: Coin flips question

Quote:
 Originally Posted by heehaww [Sum of C(365, k) from k=192 to k=365] / 2^365 ≈ 17.3% Or twice that if it can also be .5238 tails to heads.
Just to clarify, I assumed it didn't matter if it was .5238 heads or tails. If it had to be heads> tails, then you'd cut my simulation result in half, which would be 17.03%.

So at the very least since heehaww solved it formally I now know that I didn't screw up my simulation!

10-03-2018, 12:04 PM   #6
nickthegeek
journeyman

Join Date: Sep 2011
Posts: 248
Re: Coin flips question

Quote:
 Originally Posted by mkind0516 I did a quick simulation of your question (written in R ...)
Your simulation is highly inefficient. Just vectorize. After defining the initial parameters, without any loop you can just do this:

Code:
```sims<-matrix(rbinom(n.trials*days.sample,1,0.5),ncol=days.sample)
ratios<-abs(2*rowSums(sims)-ncol(sims))```
Still better is just to simulate all the days.sample together for each simulation:

Code:
```sims<-rbinom(n.trials,days.sample,0.5)
ratios<-abs(2*sims-days.sample)```

11-18-2018, 04:41 PM   #7
kraps2312
stranger

Join Date: Jan 2018
Posts: 6
Re: Coin flips question

Quote:
 Originally Posted by nickthegeek Your simulation is highly inefficient. Just vectorize.
thanks for sharing this
many do want to lower the time to run some code (as long as they can also understand it)
some do not care how long it takes

on my machine (win10 64bit, i7 quad-core. R version 3.4.4 64-bit)
the original R code using the for(), where many can easily follow and understand the code
> successes / n.trials
[1] 0.3455
> end.time <- Sys.time()
> print(end.time - start.time)
Time difference of 1.063789 mins

1st change
> successes / n.trials
[1] 0.34175
> end.time <- Sys.time()
> print(end.time - start.time)
Time difference of 0.880959 secs

2nd change
> successes / n.trials
[1] 0.348
> end.time <- Sys.time()
> print(end.time - start.time)
Time difference of 0.224988 secs
*****
anyone pick up on the reason for the OP?
the 52.38
looks to be the sportsbetting break even percentage for -110 wagers

I like seeing the calculated version also
just as a check
using pari/gp calculator
here online
pari/gp calculator
sum(k=192,365,binomial(365,k)/2^365.)

gp > x=sum(k=192,365,binomial(365,k)/2^365.);
gp > x
%2 = 0.17306096977676108864963708535391833549
(just what it prints)

gp also can give an exact result (to many is meaningless)
Code:
`%4 = 203220528468429389799192225657901180620928791059635491607434982152500715968661876726960266553086443136419117/1174271291386916613944740298394668513687841274454159935353645485766104512557304221731849499192384351515967488`

Last edited by kraps2312; 11-18-2018 at 04:54 PM. Reason: fix spelling errors

 Thread Tools Display Modes Linear Mode

 Posting Rules 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 HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Links to Popular Forums     News, Views, and Gossip     Beginners Questions     Marketplace & Staking     Casino & Cardroom Poker     Internet Poker     NL Strategy Forums     Poker Goals & Challenges     Las Vegas Lifestyle     Sporting Events     Politics     Other Other Topics Two Plus Two     About the Forums     Two Plus Two Magazine Forum     The Two Plus Two Bonus Program     Two Plus Two Pokercast     The Best of Two Plus Two Marketplace & Staking     Commercial Marketplace     General Marketplace     Staking - Offering Stakes     Staking         Staking - Offering Stakes         Staking - Seeking Stakes         Staking - Selling Shares - Online         Staking - Selling Shares - Live         Staking Rails         Transaction Feedback & Disputes     Transaction Feedback & Disputes Coaching & Training     Coaching Advice     Cash Game Poker Coach Listings     Tournament/SNG Poker Coach Listings Poker News & Discussion     News, Views, and Gossip     Poker Goals & Challenges     Poker Beats, Brags, and Variance     That's What She Said!     Poker Legislation & PPA Discussion hosted by Rich Muny     Twitch - Watch and Discuss Live Online Poker     Televised Poker General Poker Strategy     Beginners Questions     Books and Publications     Poker Tells/Behavior, hosted by: Zachary Elwood     Poker Theory     Psychology No Limit Hold'em Strategy     Medium-High Stakes PL/NL     Micro-Small Stakes PL/NL     Medium-High Stakes Full Ring     Micro-Small Stakes Full Ring     Heads Up NL     Live Low-stakes NL Limit Texas Hold'em Strategy     Mid-High Stakes Limit     Micro-Small Stakes Limit Tournament Poker Strategy     STT Strategy     Heads Up SNG and Spin and Gos     Mid-High Stakes MTT     Small Stakes MTT     MTT Community     Tournament Events Other Poker Strategy     High Stakes PL Omaha     Small Stakes PL Omaha     Omaha/8     Stud     Draw and Other Poker Live Poker     Casino & Cardroom Poker         Venues & Communities         Regional Communities     Venues & Communities     Tournament Events         WPT.com     Home Poker     Cash Strategy     Tournament Strategy Internet Poker     Internet Poker         nj.partypoker.com         Global Poker         MPN – Microgaming Poker Network         Big Ugly Poker     Commercial Software     Software         Commercial Software         Free Software General Gambling     Backgammon Forum hosted by Bill Robertie.     Probability     Sports Betting     Other Gambling Games 2+2 Communities     Other Other Topics         OOTV         Game of Thrones     The Lounge: Discussion+Review     EDF     Las Vegas Lifestyle     BBV4Life         omg omg omg     House of Blogs Sports and Games     Sporting Events         Single-Team Season Threads         Fantasy Sports     Fantasy Sports, sponsored by Draftboard.com         Sporting Events     Wrestling     Golf     Chess and Other Board Games     Video Games         League of Legends         Hearthstone     Puzzles and Other Games Other Topics     Politics     History     Business, Finance, and Investing     Science, Math, and Philosophy     Religion, God, and Theology     Travel     Health and Fitness     Laughs or Links!     Computer Technical Help     Programming International Forums     Deutsch         BBV [German]     Français     Two Plus Two en Español

All times are GMT -4. The time now is 07:29 AM.

 Contact Us - Two Plus Two Publishing LLC - Privacy Statement - Top