Twenty — minutes — maybe — more.choose four wordsmore quotes

pi day: exciting

In Silico Flurries: Computing a world of snow. Scientific American. 23 December 2017

visualization + design

The 2018 Pi Day art celebrates the 30th anniversary of $\pi$ day and connects friends stitching road maps from around the world. Pack a sandwich and let's go!

$\pi$ Day 2016 Art Posters

2018 $\pi$ day shrinks the world and celebrates road trips by stitching streets from around the world together. In this version, we look at the boonies, burbs and boutique of $\pi$ by drawing progressively denser patches of streets. Let's go places.
2017 $\pi$ day
2016 $\pi$ approximation day
2016 $\pi$ day
2015 $\pi$ day
2014 $\pi$ approx day
2014 $\pi$ day
2013 $\pi$ day
Circular $\pi$ art

On March 14th celebrate $\pi$ Day. Hug $\pi$—find a way to do it.

For those who favour $\tau=2\pi$ will have to postpone celebrations until July 26th. That's what you get for thinking that $\pi$ is wrong.

If you're not into details, you may opt to party on July 22nd, which is $\pi$ approximation day ($\pi$ ≈ 22/7). It's 20% more accurate that the official $\pi$ day!

Finally, if you believe that $\pi = 3$, you should read why $\pi$ is not equal to 3.

All art posters are available for purchase.
I take custom requests.

This year's $\pi$ day art collection celebrates not only the digit but also one of the fundamental forces in nature: gravity.

In February of 2016, for the first time, gravitational waves were detected at the Laser Interferometer Gravitational-Wave Observatory (LIGO).

The signal in the detector was sonified—a process by which any data can be encoded into sound to provide hints at patterns and structure that we might otherwise miss—and we finally heard what two black holes sound like. A buzz and chirp.

The art is featured in the Gravity of Pi article on the Scientific American SA Visual blog.

this year's theme music

All the art was processed while listening to Roses by Coeur de Pirate, a brilliant female French-Canadian songwriter, who sounds like a mix of Patricia Kaas and Lhasa. The lyrics Oublie-moi (Forget me) are fitting with this year's theme of gravity.

Mais laisse-moi tomber, laisse-nous tomber
Laisse la nuit trembler en moi
Laisse-moi tomber, laisse nous tomber
Cette fois

But let me fall, let us fall
Let the night tremble in me
Let me fall, let us fall
This time

The art is generated by running a simulation of gravity in which digits of $\pi$ are each assigned a mass and allowed to collide eand orbit each other.

The mathematical details of the simulation can be found in the code section.

exploring force of gravity in $\pi$

A simulation starts with taking $n$ digits of $\pi$ and arranging them uniformly around a circle. The mass of each digit, $d_i$ (e.g. 3), is given by $(1+d)^k$ where $k$ is a mass power parameter between 0.01 and 1. For example, if $k=0.42$ then the mass of 3 is $(1+3)^{0.42} = 1.79$.

collapsing three digits—3.14 collide

The figure below shows the evolution of a simulation with $n=3$ digits and $k=1$. The digits 3 and 4 collide to form the digit $3+4 = 7$ and immediately collides with 1 to form $7+1=8$. With only one mass left in the system, the simulation stops.

The evolution of a simulation of gravity using $n=3$ digits of $\pi$ and the mass power $k=1$. The masses are initialized with zero velocity. (zoom)

adding initial velocity to each mass

When masses have initial velocities, the patterns quickly start to get interesting. In the figure above, the masses are initalized with zero velocity. As soon as the simulation, each mass immediately starts to move directly towards the center of mass of the other two masses.

When the initial velocity is non-zero, such as in the figure below, the masses don't immediately collapse towards one another. The masses first travel with their initial velocity but immediately the gravitational force imparts acceleration that alters this velocity. In the examples below, only those simulations in which the masses collapsed within a time cutoff are shown.

The evolution of a simulation of gravity using $n=3$ digits of $\pi$ and the mass power $k=1$ in which all masses collapsed. The masses are initialized with a random velocity. (zoom)
The evolution of 16 simulations of gravity using $n=3$ digits of $\pi$ and the mass power $k=1$ in which all masses collapsed. The masses are initialized with a random velocity. (zoom)
The evolution of 49 simulations of gravity using $n=3$ digits of $\pi$ and the mass power $k=1$ in which all masses collapsed. The masses are initialized with a random velocity. (zoom)

allowing the simulation to evolve

Depending on the initial velocities, some systems collapse very quickly, which doesn't make for interesting patterns.

For example, the simulations above evolved over 100,000 steps and in some cases the masses collapsed within 10,000 steps. In the figure below, I require that the system evolves for at least 15,000 steps before collapsing. Lovely doddles, don't you think?

The evolution of 36 simulations of gravity using $n=3$ digits of $\pi$ and the mass power $k=1$ in which all masses collapsed after a minimum amount of time. The masses are initialized with a random velocity. (zoom)

exploring ensembles

When a simulation is repeated with different initial conditions, the set of outcomes is called an ensemble.

Below, I repeat the simulation 100 times with $n=3$ and $k=0.2$, each time with slightly different initial velocity. The velocities have their $x$- and $y$-components normally distributed with zero mean and a fixed variance. Each of the four ensembles has its simulations evolve over progressively more time steps: 5,000, 7,500, 10,000, and 20,000.

You can see that with 5,000 steps the masses don't yet have a chance to collide. After 7,500, there have been collisions in a small number of systems. The blue mass corresponds to the 3 colliding with 4 and the green mass to 1 colliding with 4. After 10,000, even more collisions are seen and in 3 cases we see total collapse (all three digits collided). After 20,000,

The evolution of 100 simulations of gravity over total time $t$ using $n=3$ digits of $\pi$ and the mass power $k=0.2$. Within each ensemble, the masses are initialized with a different random velocity in each instance. (zoom)

varying masses

The value of $k$ greatly impacts the outcome of the simulation. When $k$ is very small, all the digits have essentially the same mass. For example, when $k=0.01$ the 0 has a mass of 1 and 9 has a mass of 1.02.

When $k$ is large, the difference in masses is much greater. For example, for $k=2$ the lightest mass is $(1+0)^2=1$ and the heaviest $(1+9)^2=10$. Because the acceleration of a mass is proportional to the mass that is attracting it, in a pair of masses the light mass will accelerate faster.

Machine learning: supervised methods (SVM & kNN)

Thu 18-01-2018
Supervised learning algorithms extract general principles from observed examples guided by a specific prediction objective.

We examine two very common supervised machine learning methods: linear support vector machines (SVM) and k-nearest neighbors (kNN).

SVM is often less computationally demanding than kNN and is easier to interpret, but it can identify only a limited set of patterns. On the other hand, kNN can find very complex patterns, but its output is more challenging to interpret.

Nature Methods Points of Significance column: Machine learning: supervised methods (SVM & kNN). (read)

We illustrate SVM using a data set in which points fall into two categories, which are separated in SVM by a straight line "margin". SVM can be tuned using a parameter that influences the width and location of the margin, permitting points to fall within the margin or on the wrong side of the margin. We then show how kNN relaxes explicit boundary definitions, such as the straight line in SVM, and how kNN too can be tuned to create more robust classification.

Bzdok, D., Krzywinski, M. & Altman, N. (2018) Points of Significance: Machine learning: a primer. Nature Methods 15:5–6.

Bzdok, D., Krzywinski, M. & Altman, N. (2017) Points of Significance: Machine learning: a primer. Nature Methods 14:1119–1120.

Human Versus Machine

Tue 16-01-2018
Balancing subjective design with objective optimization.

In a Nature graphics blog article, I present my process behind designing the stark black-and-white Nature 10 cover.

Nature 10, 18 December 2017

Machine learning: a primer

Thu 18-01-2018
Machine learning extracts patterns from data without explicit instructions.

In this primer, we focus on essential ML principles— a modeling strategy to let the data speak for themselves, to the extent possible.

The benefits of ML arise from its use of a large number of tuning parameters or weights, which control the algorithm’s complexity and are estimated from the data using numerical optimization. Often ML algorithms are motivated by heuristics such as models of interacting neurons or natural evolution—even if the underlying mechanism of the biological system being studied is substantially different. The utility of ML algorithms is typically assessed empirically by how well extracted patterns generalize to new observations.

Nature Methods Points of Significance column: Machine learning: a primer. (read)

We present a data scenario in which we fit to a model with 5 predictors using polynomials and show what to expect from ML when noise and sample size vary. We also demonstrate the consequences of excluding an important predictor or including a spurious one.

Bzdok, D., Krzywinski, M. & Altman, N. (2017) Points of Significance: Machine learning: a primer. Nature Methods 14:1119–1120.