<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/easy-riddle/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://xianblog.wordpress.com/2017/07/12/easy-riddle/"> R – Xi'an's Og</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a rel="nofollow" href="https://xianblog.files.wordpress.com/2017/07/riddler0630.jpg" target="_blank"><img data-orig-file="https://xianblog.files.wordpress.com/2017/07/riddler0630.jpg?w=327&amp;h=327&amp;fit=327%2C327&amp;resize=327%2C327" data-orig-size="480,480" data-medium-file="https://xianblog.files.wordpress.com/2017/07/riddler0630.jpg?w=327&amp;h=327&amp;fit=327%2C327&amp;resize=327%2C327?w=300" data-attachment-id="33876" data-image-meta="{" data-image-description="" src="https://xianblog.files.wordpress.com/2017/07/riddler0630.jpg?w=327&h=327&fit=327%2C327&resize=327%2C327" data-permalink="https://xianblog.wordpress.com/2017/07/12/easy-riddle/riddler0630/" data-large-file="https://xianblog.files.wordpress.com/2017/07/riddler0630.jpg?w=327&amp;h=327&amp;fit=327%2C327&amp;resize=327%2C327?w=450" alt="" data-image-title="riddler0630" sizes="(max-width: 327px) 100vw, 327px" data-comments-opened="1" class="wp-image-33876" data-recalc-dims="1"></a><strong>F</strong>rom the <a rel="nofollow" href="https://fivethirtyeight.com/features/who-steals-the-most-in-a-town-full-of-thieves/" target="_blank">current Riddler</a>, a problem that only requires a few lines of code and a few seconds of reasoning. Or not.</p>
<blockquote>
<p><em>N households each stole the earnings from one of the (N-1) other households, one at a time. What is the probability that a given household is not burglarised? And what are the expected final earnings of each household in the list, assuming they all start with $1?</em></p>
</blockquote>
<p>The first question is close to Feller’s enveloppe problem in that</p>
<p><img alt="left(1-frac{1}{N-1}right)^{N-1}" title="left(1-frac{1}{N-1}right)^{N-1}" src="https://s0.wp.com/latex.php?latex=%5Cleft%281-%5Cfrac%7B1%7D%7BN-1%7D%5Cright%29%5E%7BN-1%7D&bg=000000&%23038;fg=B0B0B0&%23038;s=0" class="latex"></p>
<p>is close to exp(-1) for N large. The second question can easily be solved by an R code like</p>
<pre>N=1e3;M=1e6
fina=rep(1,N)
for (v in 1:M){
 ordre=sample(1:N)
 vole=sample(1:N,N,rep=TRUE)
 while (min(abs(vole-(1:N)))==0)
  vole[abs(vole-(1:N))==0]=sample(1:N,
     sum(vole-(1:N)==0))
 cash=rep(1,N)
 for (t in 1:N){
  cash[ordre[t]]=cash[ordre[t]]+cash[vole[t]];cash[vole[t]]=0}
 fina=fina+cash[ordre]}
</pre>
<p>which returns a pretty regular exponential-like curve, although I cannot figure the exact curve beyond the third burglary. The <a rel="nofollow" href="https://fivethirtyeight.com/features/how-many-critics-does-it-take-to-rank-all-the-movies/" target="_blank">published solution</a> gives the curve</p>
<p><img alt="{frac{N-2}{N-1}}^{999}times 2+frac{1}{N-1}right)^{t-1}times{frac{N-1}{N}}^{N-t}timesfrac{N}{N-1}" title="{frac{N-2}{N-1}}^{999}times 2+frac{1}{N-1}right)^{t-1}times{frac{N-1}{N}}^{N-t}timesfrac{N}{N-1}" src="https://s0.wp.com/latex.php?latex=%7B%5Cfrac%7BN-2%7D%7BN-1%7D%7D%5E%7B999%7D%5Ctimes+2%2B%5Cfrac%7B1%7D%7BN-1%7D%5Cright%29%5E%7Bt-1%7D%5Ctimes%7B%5Cfrac%7BN-1%7D%7BN%7D%7D%5E%7BN-t%7D%5Ctimes%5Cfrac%7BN%7D%7BN-1%7D&bg=000000&%23038;fg=B0B0B0&%23038;s=0" class="latex"></p>
<p>corresponding to the probability of never being robbed (and getting on average an extra unit from the robbery) and of being robbed only <em>before</em> robbing someone else (with average wealth N/(N-1)).</p>
<p>Filed under: <a rel="nofollow" href="https://xianblog.wordpress.com/category/books/" target="_blank">Books</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/category/kids/" target="_blank">Kids</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/category/statistics/r-statistics/" target="_blank">R</a> Tagged: <a rel="nofollow" href="https://xianblog.wordpress.com/tag/fivethirtyeight/" target="_blank">FiveThirtyEight</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/tag/mathematical-puzzle/" target="_blank">mathematical puzzle</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/tag/r/" target="_blank">R</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/tag/simulation/" target="_blank">simulation</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/tag/the-riddler/" target="_blank">The Riddler</a>, <a rel="nofollow" href="https://xianblog.wordpress.com/tag/william-feller/" target="_blank">William Feller</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xianblog.wordpress.com/33875/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/comments/xianblog.wordpress.com/33875/"></a> <img border="0" alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" data-recalc-dims="1"></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://xianblog.wordpress.com/2017/07/12/easy-riddle/"> R – Xi'an's Og</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/dHUiyu02Oz0" height="1"></a></div>