2 ms·
> So the starting offset between the cycles is highly important! You're missing something basic here. The program's starting point is irrelevant because it's m
by lutusp 14y ago
> So the starting offset between the cycles is highly important!
You're missing something basic here. The program's starting point is irrelevant because it's modeling a natural continuous process, one that stretches out to infinity in the past and the future (sort of like an indefinite integral). So there isn't a "starting point" in nature, only in these models.
And, because I model all the predator cycles between 1 and 30 in order to get a single result for one experimental cicada cycle, and because I model 1000 years, I have eliminated the starting point from consideration.
In nature, some predators are born in year 1, some in year 2 and so forth. Some predators have a 2-year reproductive cycle, some 3, and so forth. Those two factors are independent, and one of them answers the objection you're making (the arbitrary starting point).
But to make sure we're on the same page, here's my latest algorithm:
https://www.dropbox.com/s/7m8hq9yzcu5nztx/prime_reproduction_test.py https://www.dropbox.com/s/7m8hq9yzcu5nztx/prime_reproduction...
Note that I changed the basic algorithm to agree with that used in my Web page. It doesn't change the result, but it's perhaps easier to understand.
This version arbitrarily adds a random number 0 <= cr <= 99 to the starting year of the predator on each test, much like your original code except that my way of doing it "wraps around" within the period determined by variable b. This effort to randomize things doesn't change the result rankings -- primes always come out ahead (in the sense of fewer collisions between predators and cicadas).
Sample output:
2 = 18 ******************
3 = 18 ******************
4 = 25 *************************
5 = 16 ****************
6 = 41 *****************************************
7 = 18 ******************
8 = 37 *************************************
9 = 29 *****************************
10 = 45 *********************************************
11 = 20 ********************
12 = 52 ****************************************************
13 = 20 ********************
14 = 33 *********************************
15 = 33 *********************************
16 = 38 **************************************
17 = 19 *******************
18 = 57 *********************************************************
19 = 25 *************************
20 = 56 ********************************************************
21 = 32 ********************************
22 = 37 *************************************
23 = 21 *********************
The present form is just one of many variations I tried. I used random numbers to tweak various starting points, all with the same outcome -- primes are always favored. Because modulo arithmetic is being used, one needs to add random numbers carefully, with a clear understanding of their effect.
- jules 14y ago> So there isn't a "starting point" in nature, only in these models. Exactly, that's my whole point. And your chosen simulation starting point highly influences the outcome of the simulation. The one you chose happened to give you the prime numbers, but another would give wildly different results. > And, because I model all the predator cycles between 1 and 30 in order to get a single result for one experimental cicada cycle, and because I model 1000 years, I have eliminated the starting point from consideration. Well, no, evidently not, but I don't feel like making this point once again, the posts above explain this sufficiently. > But to make sure we're on the same page, here's my latest algorithm: This algorithm is again unreadable and wrong: a % c == 0 and b % (((c+cr) % b)+1) == 0. Why is this doing a % c, i.e. the cicada cycle modulo the simulation year?? It SHOULD be doing it the other way around: the simulation year modulo the cicada cycle. Meaningful variable names help! The fix is simple: the expression should be c % a == 0 and (c+cr) % b == 0. (also already described in my previous post) > This version arbitrarily adds a random number 0 <= cr <= 99 to the starting year of the predator on each test That's the right idea (though wrong implementation -- see above).
- lutusp 14y ago> And your chosen simulation starting point highly influences the outcome of the simulation. Yes, it does. The effect I am describing is real, and I simply haven't thought it through in detail until now. 1. The starting point for my simulation has both the cicadas and the predators hatching out simultaneously, in year zero. This obviously happens in nature as well as in my simulation (but only rarely). 2. Given that starting condition, what is the likelihood that the predator, with a range of reproduction cycles, will succeed in synchronizing with the cicadas again, or (the best of all worlds) over and over in perpetuity? 3. The answer is that, if the cicadas adopt a prime-numbered reproduction cycle, the predators are handicapped by the fact that a typical prime number has fewer divisors than a composite number, and divisors are required for synchronization: http://en.wikipedia.org/wiki/Table_of_divisors http://en.wikipedia.org/wiki/Table_of_divisors 4. For cases in which the predators and the cicadas are out of synchronization, the outcome for a random difference in years is neutral -- not advantageous, not disadvantageous. I've shown this by adding a loop to my program that tests against a range of differences in years between cicadas and predators. When I do this, the difference between a prime and a composite nearly vanishes ("nearly" because the advantage of a prime numbered cycle is still present, but is almost completely buried by the much greater number of years where there's no advantage). 5. It is only when cicadas and predators hatch out in synchrony (for any one of a number of reasons) does this prime-number effect have any effect on the outcome. 6. In terms of natural selection, this leaves the prime-number effect, plus an initial synchronization between cicada and predator, as the only selection advantage, for which the prime-number effect works against the predators. 7. Nature, and natural selection, does something my simulation doesn't -- over time, by rewarding reproductive fitness, it amplifies the effect of small advantages, in some cases turning a chance, small fitness advantage into the entire population of a species in the future. 8. I could obviously write a more complex simulation that imitates natural selection, one in which a small advantage is eventually turned into a new species, but because of the complexity of such a simulation and the amount of tuning required, I don't think this would represent anything but confirmation bias. My simulation greatly exaggerates the advantage conferred by a prime number, and it assumes something that's almost never true in nature -- that cicadas and predators hatch out in synchrony at the outset. But that set of circumstances does represent a small fitness advantage, and it probably explains the two primary reproduction cycles of the cicada species my paper describes (i.e. 13 and 17 years).