{"id":1343,"date":"2017-12-21T09:46:12","date_gmt":"2017-12-21T09:46:12","guid":{"rendered":"https:\/\/blogs.ncl.ac.uk\/stem\/?p=1343"},"modified":"2017-12-21T09:48:02","modified_gmt":"2017-12-21T09:48:02","slug":"competitive-edge-at-christmas-the-mathematical-way-to-beat-the-family","status":"publish","type":"post","link":"https:\/\/blogs.ncl.ac.uk\/stem\/2017\/12\/21\/competitive-edge-at-christmas-the-mathematical-way-to-beat-the-family\/","title":{"rendered":"Competitive Edge at Christmas \u2013 the mathematical way to beat the family"},"content":{"rendered":"<h5>Toilet Trouble is the must-have family game this festive season. Determined not to be flushed away by their families, our Mathematics lecturers, Dr Andrew Baggaley and Dr Nick Parker got ahead of the game to analyse the seemingly random sequence of flushes and squirts.<\/h5>\n<p>On Christmas morning many families will wake up to a rather unexpected gift from Santa Claus: \u201c<strong><a href=\"https:\/\/www.hasbro.com\/en-gb\/product\/toilet-trouble-game:B06CC032-5056-9047-F563-B04A09872EB9\">Toilet Trouble<\/a><\/strong>\u201d.\u00a0 This does not involve an emergency call to your local plumber or your GP, but is rather a family game devised by Santa\u2019s most mischievous elves.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1344\" src=\"https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/toilet-game1-1024x683.jpg\" alt=\"\" width=\"604\" height=\"403\" srcset=\"https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/toilet-game1-1024x683.jpg 1024w, https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/toilet-game1-300x200.jpg 300w, https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/toilet-game1-768x512.jpg 768w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/p>\n<p>Each player nervously awaits their fate as they place their face over the toilet bowl and flush the handle.\u00a0 If they are lucky, they breathe a sigh of relief at staying dry and the suspense moves to the next player; if they are unlucky, a jet of toilet water comes to greet them.\u00a0 Is this squirting truly <strong>random or is there some hidden order<\/strong>?\u00a0 Can the occurrence of the next tinkle be predicted?\u00a0 And can you beat the odds to stay dry, while soaking your nearest and dearest?\u00a0 Here we <strong>self-proclaimed wizz kids<\/strong> combine scientific experimentation and mathematical analysis to give you the edge in this festive problem.<\/p>\n<p>We put the game to the test by flushing the toilet over 1000 times and noting whether the jet squirted or not.\u00a0\u00a0 The data was conveniently recorded in <strong>binary format<\/strong> as a series of zeros ( = no squirt, dry) or ones (= squirt, wet).\u00a0 The dataset, shown below, appears random with no evident pattern.\u00a0 However, just because it looks random, is it random?\u00a0 A large area of mathematics is devoted to analysing such patterns, seeking out hidden order and the information that this may carry, from identifying the trends in stock markets to deciphering information embodied in secret communications.\u00a0 On the flip side of this latter example is the branch of mathematics which creates the codes in the first place; <strong>cryptography<\/strong> designs tricks to hide information in a jumble of numbers.\u00a0 Central to this are the \u201c<strong>pseudo-random-number generators<\/strong>\u201d, mathematical functions which produce a seemingly random series of numbers but which are nonetheless orderly mathematical functions &#8211; if we start the function from the same number we will always get the same random-looking series of numbers being produced.\u00a0 In this sense, <strong>the numbers only appear random<\/strong>.\u00a0 An everyday example of pseudo-random-number generation is when we play our music tracks on shuffle.\u00a0 Interestingly, however, a good generator would mean that there was a chance that the same number (music track) would be produced twice in a row, or within a short interval. For example if you create a random playlist from a 10 track album, there is a 10% chance that you would have to listen to the same track twice in a row. To avoid this unwanted effect, the original number generators used for shuffling had to be tweaked to prevent the same track arising in close succession.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1346\" src=\"https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/binary-1024x570.png\" alt=\"\" width=\"604\" height=\"336\" srcset=\"https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/binary-1024x570.png 1024w, https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/binary-300x167.png 300w, https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/binary-768x428.png 768w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/p>\n<p>We return to the matter at hand &#8211; the \u201crandom\u201d squirting of the toilet.\u00a0 As is typical of scientific analyses, we begin our analysis at the most basic level, before drilling down to increasing detail until we reach a required level of understanding of the problem.\u00a0 From the data (see image) it is evident that the squirts (ones) are relatively spaced out.\u00a0 In other words, at each flush there is not an equal 50:50 chance between squirt or no squirt &#8211; the chance is <strong>biased towards not being squirted<\/strong>, which is some good news for the players.\u00a0 Our<strong> 1000 flushes produce 196 squirts<\/strong>, informing us that, on average, there are 5.1 flushes between squirts.\u00a0 This doesn\u2019t help us to identify whether or not there is a pattern to the squirts, and so next we look at the number of flushes between squirts, shown below.\u00a0 Several important features now become evident.\u00a0 There is not an equal chance of a squirt for all number of flushes, and this allows us to ascribe a confidence\/concern scale. If it is your turn to flush immediately after a squirt has taken place, you can give your most cocky grin at the toilet bowl and your fellow players &#8211; no squirts arise on this turn.\u00a0 If you flush on the second, sixth or eighth flush after the previous squirt, you can smile with a confidence at the bowl &#8211; these turns have less than 5% chance of squirting.\u00a0 If you take the<strong> fourth flush<\/strong>, then have your towel handy &#8211; this leads to the <strong>highest chance of squirting, over 30%<\/strong>.\u00a0 Finally, if you are about the take the tenth flush then brace yourself for a guaranteed soaking since <strong>all squirts happen within ten flushes<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1347\" src=\"https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/graph-1024x699.png\" alt=\"\" width=\"604\" height=\"412\" srcset=\"https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/graph-1024x699.png 1024w, https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/graph-300x205.png 300w, https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/graph-768x524.png 768w, https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/graph.png 1528w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/p>\n<p>If the squirting were entirely random, then the distribution in the histogram would be flat; the fact that it varies indicates that there is some <strong>hidden order<\/strong> which, for example, favours the fourth flush and suppresses the first, second, sixth and eighth flushes.\u00a0 Closer examination of the squirting reveals a pattern in which the squirting fires around the 10th, 3rd, 4th, 8th, 4th, 4th and 5th flushes.\u00a0 This pattern then repeats.\u00a0 So the squirting is orderly after all, it is just the irregularity of this pattern that creates an illusion of randomness.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1348\" src=\"https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/graph2-1024x172.png\" alt=\"\" width=\"604\" height=\"101\" srcset=\"https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/graph2-1024x172.png 1024w, https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/graph2-300x50.png 300w, https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/graph2-768x129.png 768w, https:\/\/blogs.ncl.ac.uk\/stem\/files\/2017\/12\/graph2.png 1298w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/p>\n<p>So how random is our game? In order to understand this we can compute the<strong> <em>entropy <\/em><\/strong>of the squirt signal, a single number which will quantify this.\u00a0 If you have met the idea of entropy before then it was probably in the context of disorder.\u00a0 Indeed one of the most important laws of physics tells us that <strong>the natural tendency of any isolated system is to become more disordered<\/strong>. Leave a young child in a tidy bedroom and they will soon provide a definitive proof of this.<\/p>\n<p>However we can also apply this idea to a random signal. Imagine flipping a fair coin lots of times and noting down a 1 if it is heads and 0 if it is tails. This would build up a signal of 1\u2019s and 0\u2019s which is completely random. If we computed the entropy of this signal we would find it is one. On the other hand imagine a coin which is completely biased, it always landed showing the head. This signal would be completely predictable, it would always be a 1, and the entropy would be zero. From our data we expect a squirt roughly with a probability of around 1 in 5, a truly random signal of 1s and 0s with this probability has an entropy of 0.72. What about our game? We find the entropy of our signal is a little lower, almost exactly 0.7, expressing the fact that our data has some intrinsic pattern.<\/p>\n<p>Will this understanding allow us to stay dry on Christmas morning?\u00a0 Well no.\u00a0 The number of flushes that a player must make is random, decided by spinning a wheel numbered from 1 to 3.\u00a0 This serves to ensure that <strong>each player has no control over their own destiny<\/strong>.\u00a0 You can predict when the squirts will fire but you can\u2019t control whether they will fire on you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Toilet Trouble is the must-have family game this festive season. Determined not to be flushed away by their families, our Mathematics lecturers, Dr Andrew Baggaley and Dr Nick Parker got ahead of the game to analyse the seemingly random sequence of flushes and squirts. On Christmas morning many families will wake up to a rather &hellip; <a href=\"https:\/\/blogs.ncl.ac.uk\/stem\/2017\/12\/21\/competitive-edge-at-christmas-the-mathematical-way-to-beat-the-family\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Competitive Edge at Christmas \u2013 the mathematical way to beat the family<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3103,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[164,150,326,154],"class_list":["post-1343","post","type-post","status-publish","format-standard","hentry","category-articles","tag-binary","tag-christmas","tag-cryptography","tag-maths"],"_links":{"self":[{"href":"https:\/\/blogs.ncl.ac.uk\/stem\/wp-json\/wp\/v2\/posts\/1343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ncl.ac.uk\/stem\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ncl.ac.uk\/stem\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/stem\/wp-json\/wp\/v2\/users\/3103"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/stem\/wp-json\/wp\/v2\/comments?post=1343"}],"version-history":[{"count":4,"href":"https:\/\/blogs.ncl.ac.uk\/stem\/wp-json\/wp\/v2\/posts\/1343\/revisions"}],"predecessor-version":[{"id":1351,"href":"https:\/\/blogs.ncl.ac.uk\/stem\/wp-json\/wp\/v2\/posts\/1343\/revisions\/1351"}],"wp:attachment":[{"href":"https:\/\/blogs.ncl.ac.uk\/stem\/wp-json\/wp\/v2\/media?parent=1343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/stem\/wp-json\/wp\/v2\/categories?post=1343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/stem\/wp-json\/wp\/v2\/tags?post=1343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}