Live data from Hacker News

Fireflies

ncase.me

71–80 of 93 posts

Re: Fireflies

#71

Nature has the best algorithms, don't it folks? I have a question about a detail. The rule is: 1. When you see a nearby neighbour flash, nudge your own clock forward. 2. That's it. My question is -- when the fireflies are firing at the same time, they see each other flash, so they all nudge their clocks forward, correct? Assuming they don't nudge their clocks forward at the same amount, they would fall out of sync, c…

"Speeding up" would only happen when you turn nudging on, it wouldn't continuously keep getting faster.

But the algorithm described by the author has a bigger problem: It wouldn't actually sync the fireflies!

If EVERYONE nudged their clocks forward, then an out-of-sync firefly would be nudged the same as an in-sync firefly, and synchronization wouldn't increase over time!

Your rule avoids this problem:

> If you see a neighbour nearby flash, when you are not flashing, nudge your clock forward by a bit.

If you look in "show clocks" mode, it looks like this is exactly what is implemented.

Re: Fireflies

#73

Yay ncase did it again! Don't forget to (re)view his project on The Parable of the Polygons: https://news.ycombinator.com/item?id=8716538 Playable posts are amazing. Interactivity in texts is amazing. <3

If you like interactive posts with lots of play, check out Bret Victor's work (if you haven't already). Good start here: http://worrydream.com/ClimateChange/

Fun fact which I heard on a conference about gaming: Vihart (who ncase collaborated with) worked together with Bret Victor.

Disclaimer: not sure if memory serves me right though O:)

Re: Fireflies

#74

Why would a firefly that sync survive more than one which doesn't?

Good question. My initial guess: it is easier for predators to detect/catch fireflies that blink out of sync with the rest of the flock. If all blink in perfect synch, it's just a big flash of light to the predators.

Re: Fireflies

#75

Earlier quoted context omitted.

I think that's why it works -- if you change that = to a %=, the effect no longer happens. It does make (intuitive) sense, though, because the only time that makes a significant difference is when a lot of fireflies flash around one firefly simultaneously, in which case the firefly wouldn't decide to flash twice in a row but instead interpret it as a singular flash. And if a firefly sees another one flash when it's a…

Right- but the explanation in the 'explorable' is that the effect happens due to the simple pattern of Step 1: When you see a nearby firefly flash, nudge your clock a little bit forward, Step 2: That's it. Problem is, the description of what's happening and what is actually happening doesn't match.

Another poster here showed their own, similar demo of this. There they had each firefly charging like a capacitor. Triggering the light causes the capacitor to deplete. This seems like the better analogy, but more people know what clocks are.

Re: Fireflies

#77

Nature has the best algorithms, don't it folks? I have a question about a detail. The rule is: 1. When you see a nearby neighbour flash, nudge your own clock forward. 2. That's it. My question is -- when the fireflies are firing at the same time, they see each other flash, so they all nudge their clocks forward, correct? Assuming they don't nudge their clocks forward at the same amount, they would fall out of sync, c…

At least in the Kuramoto model, it's a little more complicated than the OP makes it sound (but not much). Step 1 is more like "if you see a flash, bump your clock closer to midnight."

Specifically, an ODE is given for firefly $i$'s phase angle $ \theta_i$

$$\dot\theta_i = \omega_i + K / N \sum_{j=1}^N \sin(\theta_j - \theta_i)$$

This gets interesting because the flies natural frequencies $\omega_i$ are also assumed to be randomly distributed. So you don't get perfect phase-synchronization--flies with fast natural frequencies lead the pack as it loops around the phase ring, and flies with slow natural frequencies are dragged along at the back. Relative to the mean phase, your excess phase approaches a smooth increasing function of your natural frequency. But, for high enough values of $K$, you do get frequency-synchronization--everyone oscillates at the average frequency.

(For low values of $K$, or too-large natural frequencies, "rogue oscillators" emerge in a SNIPER bifurcation. They zoom around the phase ring at a different frequency, briefly slowing as they pass through the cloud of synchronized oscillators. Also applies for too-slow rogues.)

In the video and the OP's simulation, it looked the natural frequencies were all pretty similar, if not the same. However, there was a second addition that is not in the original Kuramoto model (but is in most subsequent models): rather than observing all other flies, only observe nearest neighbors. This can be added by putting a symmetric boolean adjacency matrix $A_{i,j}$ right before the $\sin$ in the previous equation.

This has the effect of making excess phase a smooth function of not only the natural frequency, but also some structural feature imposed by the network. In random networks like Erdos-Renyi, this feature is the node degree, but in the video it looks like it might be the long axis of the bush (so, like, one of the eigenvectors of the graph Laplacian).

(In general, coupled oscillators, such as circadian gene clocks, show this smooth dependence of excess phase on per-unit heterogeneities, which is the topic for the first half of my PhD dissertation. The second half is figuring out what the heterogeneities are when you only have recordings of the dynamics to go by.)

Re: Fireflies

#78

The background noise is so soothing. http://ncase.me/fireflies/sounds/forest.mp3

Yeah, although my volume is down low and I opened the page in another tab while I was reading. By the time the sound permeated my consciousness, I thought that I had a hard drive going bad in my NAS next to my laptop.

Re: Fireflies

#79
post #16

Apologies for what might be shameless self-promotion, but if you're interested in this idea, you might like my 2012 project , "The Kuramoto Model (1,000 Fireflies)." I built 1,000 microcontroller-based LED devices that synchronized with each other using radio communication, with a similar algorithm to what Nicky used. Link is here: http://davidrueter.com/projects/2012-the-kuramoto-model.html

Very good result although the green mind in me screams a bit when thinking about all this waste.
Post reply on HN