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