A blog of Python-related topics and code.

The double pendulum

In classical mechanics, a double pendulum is a pendulum attached to the end of another pendulum. Its equations of motion are often written using the Lagrangian formulation of mechanics and solved numerically, which is the approach taken here. The dynamics of the double pendulum are chaotic and complex, as illustrated below.

A very simple 2-D diffusion model

A very simple diffusion simulation can be constructed in two dimensions by following the positions of a number of "particles" which all start off at the centre of a grid of cells. Time is assumed to progress in a series of "ticks": at each tick, each particle's position changes at random by $-1$, $0$, or $+1$ cells in each of the $x$ and $y$ directions.

Has April in Cambridge, UK been unusually dry?

In 2016 it seemed that Cambridge, UK was unusually cold. News reports this year have suggested that April 2017 has been unusually dry. To determine to what extent this is true (again, in Cambridge), I downloaded the monthly weather summaries from the Cambridge University Digital Technology Group. This is easily done using a few lines of bash:

Power Spectra for "Blue" and Uniform Noise

The previous post provided some code for generating Poisson disc noise (in which no point the sample is closer than some fixed distance from any other). Here is a short program to calculate the power spectrum of this noise and compare it with the spectrum for the same number of points drawn from a uniform distribution.

Poisson disc sampling in Python

A set of points drawn from a uniform distribution on a two-dimensional domain typically display clustering: