Music relies on repetition: we expect the beat to return, like a chorus coming back. But if you repeat the same thing for too long, it gets boring. The composer seems to walk a tightrope between the familiar and the unexpected.
Scientists translated this balance into the language of physics. They represented rhythm as a system where each note is a particle that 'wants' to be like its neighbors (order) but also 'wants' to be different (variety). In physics, such opposing forces are described by free energy — a quantity that tells how stable a system is. It turned out that under certain conditions, a phase transition occurs in rhythm: just as water turns into ice, disordered beats suddenly snap into a clear pattern.
The model was tested on the music of Johann Sebastian Bach. His rhythmic patterns turned out to be very close to those predicted by the model. This means that Bach intuitively found that very balance between predictability and surprise that physicists described with formulas.
This approach can be useful not only for analyzing old music but also for creating new music. A composer or a program can tune the 'temperature' of the rhythm: more order (you get a march, more chaos) free improvisation. Music, like matter, has its states.
In the model, rhythm 'freezes' into a pattern just as water turns into ice. Only instead of temperature, it's the ratio between the drive for repetition and the craving for novelty.