Fireflies
ncase.me
ncase.me
Playable posts are amazing. Interactivity in texts is amazing.
<3
Disclaimer: not sure if memory serves me right though O:)
I saw your comment: "The cells need not have identical individual frequencies to reach sychronization."
This seems counter-intuitive to me.
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 about to, it would naturally want to synchronize its flashing with the other.
So what this line does (which is in the section of code where a flash alters the fireflies around it) is that after advancing the other fireflies clocks, if any are over 1 then it puts them in the right state to flash on the next time they're evaluated. If you mod it, then you would have the logic:
"if I'm a firefly and see my neighbour flash while just about to flashing myself, don't flash but reset my clock to part way through the cycle"
rather than
"if I'm a firefly and see my neighbour flash while just about to flashing myself, flash as well"
Edit - setting it to one ensures that each neighbour can't keep adding to the clock, advancing it to a random point in the cycle.
On the subject of fireflies and emergent patterns, RadioLab did a wonderful podcast on the subject as well a few years ago: http://www.radiolab.org/story/91500-emergence/ This piece very much reminded me of that.
This is adaptation to input disruption on a network of brain impulses. Fascinating that so much correlates with our own perception and technologies.
Really great interactive post both informative and engaging.
The dates get announced a month or so beforehand, and tickets are based on a lottery system since it only[2] occurs on one side of one river for less than a mile. You can technically also hike in if you're ok with 8 or so miles near sunset and then the same amount out in the pitch black. I believe that is frowned upon, but very few people do it that way (I was the only one the year I couldn't get tickets and decided to hike).
[1] https://www.flickr.com/photos/23215983@N02/albums/7215764507...
[2] Not exactly only, but certainly the most strongly.
open source time to read
but with regard to say if it was a real-time rendered animation, then calculating the point of origin and affecting the nearby fireflies... hmm
the view clock part was particularly impressive though I could see it as a state thing, still so many of them on the same page, not crashing the browser or something interesting. Maybe I'm over thinking it.
edit: I didn't look at the scripts though below the canvas.
[0] https://ccl.northwestern.edu/netlogo/models/Fireflies [1] http://ccl.northwestern.edu/netlogo/index.shtml
Did they ever figure out why Thailand fireflies do this, instead of just how?
http://www.sciencedirect.com/science/article/pii/S0378437116...
I understand advancing your clock to synchronize flashes, but doesn't this presuppose that the clocks run at the same speed?
When I turned on "Show Clocks" in the simulation it indeed looked like the clocks ran at identical durations. Seems like this would be difficult in nature.
Some of these processes use physical latency to time the events: if the fireflies were roughly of the same maturity, they would be of similar size and thus have clocks of similar duration.
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, correct? But they stay in sync, so they must nudge forward at the same amount...is this right?
So my question is -- if everyone keeps nudging their clocks forward, why don't they keep speeding up? They do appear instead to continue flashing at the same steady rate.
Does this mean that there ought to be another detail in the rule, such as,
If you see a neighbour nearby flash, when you are not flashing, nudge your clock forward by a bit.
? Or is the perspective I just said missing something?
From: https://www.math.hmc.edu/~dyong/math164/2006/runyeon/finalre...
I think this is it. There could be some missing detail (e.g. a firefly is unable to "see" when it flashes) which keeps them from nudging their clocks once already in sync
Does it matter if they "nudge their clocks once already in sync" ? If they all do that, they'll stay in sync, with a slightly higher frequency.
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.
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.)
What's the quickest way to preview that (without needing a hosted service)?
I just made this small LaTeX document (I'm amazed I knew this by heart, I typed this manually maybe thrice in my life):
\documentclass{paper}
\begin{document}
$$\dot\theta_i = \omega_i + K / N \sum_{j=1}^N \sin(\theta_j - \theta_i)$$
\end{document}
<esc>:wq
pdflatex tmp.tex && evince tmp.pdf && rm tmp.*
but that's still quite a bit of extra work just to view it. Do you know a better way to do it?http://www.HostMath.com/Show.aspx?Code=%5Cdot%5Ctheta_i%20%3...
Why it's sitting down on the second page with just a few upvotes is beyond me.
If you changed the grid geometry, changed the action radius, or added a more complicated decision mechanism, it is likely to result in a completely different outcome. It is more like a cellular automaton than a sociological model, compounding design choices, not agent choices.
It should probably be called Parable of the Quantization Error instead and held up as an example of an explorable explanation being misused for propaganda purposes, using its medium to present a false image of impartiality.
Your objection is just that the model is too simple, but everyone knows linear regression predicts quite a lot, quadratic polynomials estimate physical motion very well, etc.
On the other hand, I don't think the authors make the claims about faithfully and objectively measuring reality that you say they do. You're building up a straw man there.
(I don't generally like looking at people's comment history, but one, you're absolutely spot-on that it would be easy to change the simulation - it's public domain and it's in JavaScript, this is Hacker News, if you don't know how to edit the JS console yourself there are tons of people who will gladly help if you ask, so the lack of curiosity is interesting. And two, I've seen some sort of shift in more vocal MRA-adjacent / alt-right-adjacent viewpoints on this site in recent weeks and I've been kind of curious where it's coming from.)
Anyway, in the hope of not dragging this too far off-topic: 'tnone, do you have a specific change you'd like to see implemented in the simulation? I'd be happy to implement the change and rehost it and see what happens. I think there are genuine criticisms to be made (for instance, https://github.com/ncase/polygons/issues/9 sounds worth some investigation, despite the phrasing of the comment thread). But given how easy it is to apply actual data to these questions, I think we should do that to avoid FUD.
In particular, how about changing the radius to be the surrounding 24 squares (two steps out, instead of one), or making it less likely that an individual polygon will move again shortly after it has moved?