Posts

Showing posts from 2020

Magic Triangle - Solved

Image
Magic Triangles This puzzle features in  CSIRO 's  Double Helix  blog post,  A Magic Triangle Brainteaser . The  Magic Triangle  problem involves arranging integers on a triangle. Consider a triangle with a circle at each vertex and along each side: Arrange the numbers 1 to 6 in the circles so that each side sums to the same value. This specific challenge requires each side to sum to 10. Method for Triangles First, label the nodes sequentially starting from any vertex: The solution involves the following steps: Generate all permutations of numbers 1 to 6 as  a ,  b ,  c ,  d ,  e ,  f . Filter permutations to satisfy the magic shape condition: $a + b + c = c + d e = e + f + a$. Apply the final condition:  a  +  b  +  c  = 10 . Using Haskell Generate all permutations of the numbers 1 to 6: import Data.List permutations [ 1 .. 6 ] This yields  6! = 720  permutations. Filter for sides with equal sums: [ [(a,b,c), (c,d,e), (e,f,a)] | ...

Viral Maths Problems

Image
Every year, we see a fresh wave of 'viral' maths problems. You know the ones: 'Can you solve this?' The catch is, they rarely give you the answer, and the equations are usually a mess. Let's unpack one of these problems to see why they’re so confusing—and how we can actually fix them. Example The last one I saw online was the challenge: Can you solve? 8 ÷ 2(2+2) My first observation is the unusual use of ÷ (mathematicians prefer / ) and bad bracketing. Let us clean up the expression to clear up some ambiguity: 8 ÷ 2 × (2+2) This makes it much easier to the next step of applying BODMAS  (US refers to this as PEDMAS ) . The order of operations here are: Solve the Brackets, then From left to right apply division's and multiplications From left to right apply addition's and subtraction's Here: division and multiplication have equal precedence as do addition and subtraction. Applying these operations gives: 8 ÷ 2(2+2) =  8...

Anomaly Detection and Change Point Detection - Reproduced

Image
Ano malies are patterns in the data that do not conform to a well-defined notion of normal behavior. Techniques used to detection anomalies typically require training before using on new data. Here we will reproduce the results from  Oana Niculaescu 's article in  XRDS ,  Applying Data Science for Anomaly and Change Point Detection . This article was generated using a Jupyter Notebook. The notebook is available  here . Detecting Changes The  CUSUM  algorithm is used to test for anomalies. This requires two parameters:  threshold  and  drift . But, how do you choose values for these parameters? Gustafsson (2000) provides this recipe: Start with a very large  threshold . Choose  drift  to one half of the expected change, or adjust drift such that  g = 0  more than 50% of the time. Then set the  threshold  so the required number of false alarms (this can be done automatically) or delay for detection is obtained...