Blog

Viewing posts by christian

Ratios of random numbers

The last episode of 3Blue1Brown's "lockdown math" series posed the problem: given two numbers, $x$ and $y$, chosen randomly from the uniform distribution between 0 and 1, what is the proportion that their ratio, when rounded down to the nearest integer, is even? That is, what is $P(\lfloor \frac{x}{y} \rfloor \mod 2 = 0)$?

The Babylonian spiral

A Babyonian spiral (OEIS A256111) is the figure formed by starting with a zero-vector at the origin and concatenating vectors such that each subsequent vector is the next one longer than the previous one that also lands on a position with integral Cartesian coordinates. That is, the $i$th vector has integer components $x_i$ and $y_i$ satisfying, $x_i^2 + y_i^2 = n_i^2 > n_{i-1}^2$. Each vector is chosen such that it minimizes the angular separation from the previous one.

Hexagonal Truchet tiling

Following on from this earlier post, here is a class, TruchetHexes, which generates a pleasing weave-like pattern by tiling the following hexagon shapes in random orientations.

Inflation in Austria

STATISTICS AUSTRIA provides economic and demographic statistical services to the state of Austria. This page lists the Consumer Price Index it calculates every month according to a methodology that is updated every five years.

Quadtrees #2: Implementation in Python

The following code implements a Quadtree in Python (see the previous blog post). There are three classes: Point represents a point in two-dimensional space, with an optional "payload" (data structure associating the Point with more information, for example the identity of an object). The Rect class represents a rectangle in two-dimensional space through its centre, width and height. There are methods to determine if a given Point object is inside the Rect and to determine if the Rect intersects another Rect.