Created
August 30, 2013 01:52
-
-
Save actsasgeek/6385480 to your computer and use it in GitHub Desktop.
Poincare's Bread Supposedly, Poincaré suspected that his local bakery was selling loaves of bread that were lighter than the advertised weight of 1 kg, so every day for a year he bought a loaf of bread, brought it home and weighed it. At the end of the year, he plotted the distribution of his measurements and showed that it fit a normal distri…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pick_heaviest_loaf <- function( loaves=100) { | |
bread <- rnorm( loaves, 950, 50) | |
return( max( bread)) | |
} | |
loaves_over_a_year <- function( loaves=100) { | |
days <- 365 | |
poincare_loaves <- vector() | |
for (i in 1:days ) { | |
heaviest_loaf <- pick_heaviest_loaf(loaves) | |
poincare_loaves <- append( poincare_loaves, heaviest_loaf) | |
} | |
return( poincare_loaves) | |
} | |
loaves <- loaves_over_a_year(100) | |
summary( loaves) | |
hist( loaves) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment