String substitutions Note - the package I wrote was originally inspired by a challenge a coworker tossed out. It also happened to provide a solution to this SO question which was really cool! Substitutions in strings are best handled with regular expressions which are an amazingly powerful and flexible tool. Regular expressions are a way of expressing patterns in strings. In the example below I want to find the four letters, “dopa” and replace them with “meta”.
Fermat and his library This morning I woke up to a delightful tweet from fermatslibrary about sample random uniform numbers and how many it takes, on average, to sum to 1. Pick a uniformly random number in [0,1] and repeat until the sum of the numbers picked is >1. You’ll on average pick e≈2.718… numbers! pic.twitter.com/8ak1hYENCi — Fermat’s Library (@fermatslibrary) October 28, 2017 If you look at the embedded picture, you can see the math sketched out but of course it’s alwasy more fun to simulate.
Learning the hard way About a month ago David Robinson made a tweet that I both agree and disagree with. New blog post: “Don’t teach students the hard way first” https://t.co/X2drh1tQe5 #rstats pic.twitter.com/GXAEpx5eET — David Robinson (@drob) September 21, 2017 His example is simple enough - you’re going to a friends new house and are provided with directions involving a lot of back roads, twisting and turning. When you arrive you’re told to just take the highway back because it’s easier.