Welcome to my new blog, modelxy! This has been a long time coming, the last time I've blogged was around 2017 and I can't believe all that time has gone by without me sharing much to the world.

Well that stops today. I'm resolved to get back into the swing of things. I might be a little rusty and need some practice, but I have a lot to say and a lot to share, so here goes!

One of the big reasons I've been hesitant to start writing on a blog has been the friction around sharing code easily. I really like being able to understand and explain concepts through the lens of writing code. Using most blog engines makes for a sub-optimal solution of running code somewhere else and then copy-pasting it into formatted code snippets. I much rather prefer mixing code and prose like I can do in a Jupyter Notebook.

Thus this blog is powered by Fastpages, and as much as possible I'll be writing posts as notebooks.

In fact, this post was written as a Notebook! To prove it, here is an rendering of the Sierpiński triangle made using the Chaos Game Method1.

import numpy as np

import matplotlib.pyplot as plt
plt.figure(figsize=(20, 10), dpi=80)

image_size = np.array((1000, 1000))
r, nsides, npts = 0.5, 3, 500000

# The vertices of a regular polygon with nsides sides and a vertex pointing up,
# calculated on the unit circle centered at (1,1)
polygon = [(np.cos(phi)+1, np.sin(phi)+1) for phi in
                                    np.arange(0, 2*np.pi, 2.*np.pi/nsides)]
# Map vertices to image pixels
pts = (np.array(polygon) * 0.5 * (image_size-1))
# Initial point at centre of polygon
p1 = np.array(image_size/2)
aimg = np.zeros(image_size)

# Play the Chaos Game!
for i in range(npts):
    irow = np.random.randint(nsides)
    p2 = pts[irow]
    p1 = (p1 * r + p2 * (1-r))
    aimg[tuple(p1.astype(int))] += 1


Isn't that quite beautiful? When I first learned about fractals I was deeply struck by how such complex structure can emerge from very simple building blocks. When using a process such as the chaos game to construct our fractal, it's incredible that order can emerge from chaos.

These are the lessons I take when it comes to my humble new blog. My hope is that over time some each nugget of information I can share can build up to a greater whole. I plan to write about a diverse set of topics, whatever I find to be intellectually interesting. My wish is that some kind of order can emerge from this chaos.

The world is full of beautiful ideas and this blog is a celebration of all that beauty. Let's have fun exploring together!