Box counting in Cython
A Cython extension that estimates the fractal dimension of a point set by counting occupied cells, without building the whole grid. I wrote it on my own in one month, between November and December 2022.
The problem
To measure the dimension of an attractor with box counting you count how many cells of side ε contain at least one point. With many points or many dimensions the full grid takes too much memory. I used a tree that branches only where there are points.

How it works
- 01
The tree
A recursive N-ary tree written in C inside Cython: each level halves the cell side and only occupied branches are created. The tree memory is freed by hand with free().
- 02
The fit
occupation counts the cells at each level; fit_show does the linear fit with SciPy and shows the plots.
- 03
Tests
On the Hénon and Lorenz attractors, with figures saved in the repository.
What I did
All the code, 19 commits, about 530 lines of Cython and Python.
Limits
One-line README, no documentation, test scripts run by hand. I did not measure how much faster it is than a grid, so I claim nothing.
Stack: Python, Cython, C, NumPy, SciPy, Matplotlib.
