wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> medium >> Frisky elephants problem
(Message started by: BenVitale on Feb 3rd, 2008, 12:21pm)

Title: Frisky elephants problem
Post by BenVitale on Feb 3rd, 2008, 12:21pm
How many years will it take two elephants to reach a population of 15 million.

Assumptions:
Elephants live 100 years old.
Elephants breed between the ages of 30 and 90.
Each female gives rise, on average, to 6 baby elephants (on average, half male half female).
All elephants are fertile and live a full life.

Title: Re: Frisky elephants problem
Post by towr on Feb 3rd, 2008, 12:35pm
[hide]For large numbers of elements, there's an annual growth of 3%-1% = 2% per year
So we get log(1500000/2)/log(1.02) ~= 680 years.[/hide]

There's more accurate ways to get an answer though, but they take a bit more time to work out..

Title: Re: Frisky elephants problem
Post by towr on Feb 3rd, 2008, 1:55pm
[hide]Simulating the process, I get 842

(And of course, I missed a 0 in my last solution, 1.5 million and 15 millions aren't quite the same. I should have gotten about 800 as the answer there.)[/hide]

Title: Re: Frisky elephants problem
Post by BenVitale on Feb 3rd, 2008, 2:08pm
towr, thanks.
did you write a program? could you show us the script?

Title: Re: Frisky elephants problem
Post by BenVitale on Feb 3rd, 2008, 2:11pm
How did you get the 2% annual growth rate?

Title: Re: Frisky elephants problem
Post by towr on Feb 3rd, 2008, 2:17pm

on 02/03/08 at 14:08:03, BenVitale wrote:
towr, thanks.
did you write a program? could you show us the script?
I can, but it's not very pretty. However, you can run it in your browser (just put it all on one line, and enter it in the location bar).


Code:
javascript:
a=[2];
for(i=1; i<100; i++)
 a[i]=0;
x=0;
while(true)
{
 document.write(x+':  ');
 for(i=0;i<100;i++)
   document.write((Math.round(10*a[i])/10)+'  ');
 document.write('<br>');

 t=0;
 for(i=0;i<100;i++)
   t+=a[i];
 if(t>15000000)
   break;

 r=0;

 for(i=30;i<90;i++)
   r+=a[i];

 for(i=98;i>=0;i--)
   a[i+1]=a[i];

 a[0]=r/10/2;

 x++;
}
alert(x);




on 02/03/08 at 14:11:44, BenVitale wrote:
How did you get the 2% annual growth rate?
3% reproduction rate, 6 babies per 100 pairs of elephants
1% death rate, every elephant at age 100.
This is quite obviously wrong, because both numbers assume a stable population size :P
The result is surprisingly close though.

Title: Re: Frisky elephants problem
Post by Obob on Feb 3rd, 2008, 2:37pm
There is also the chance that the first two elephants will have exclusively females or males; how does this enter into the calculation?

Title: Re: Frisky elephants problem
Post by towr on Feb 3rd, 2008, 2:48pm

on 02/03/08 at 14:37:06, Obob wrote:
There is also the chance that the first two elephants will have exclusively females or males; how does this enter into the calculation?
Well, there are fish that can change sex if there's too few of one sex; surely elephants as a higher class of animal should be able to pull that trick off as well ;)

It would be a lot more complicated to take every factor into account and give a proper expected #years until the population reaches 15 million. Even if the first couple are different sex (50% chance), there's some chance all their children are the same sex.
(Not to mention the inbreeding will probably cause some problems).
I'm not sure how many factors you can sensibly take into account; but I'm sure SMQ might take a shot at amazing us. (Especially now that I mention it, muahaha ;))


I suppose you could just run a detailed simulation a few thousand/million times, and give some statistics on the average and deviation, and anything else of interest.

Title: Re: Frisky elephants problem
Post by BenVitale on Feb 3rd, 2008, 5:58pm
If we are deliberately as generous as possible, assuming everything is going as perfectly as possible, then

log(15 000 000 / 2) / log(1.02) = 799.409762 or 800 years.

right?

Title: Re: Frisky elephants problem
Post by BenVitale on Feb 3rd, 2008, 9:38pm
I have reconsidered the solution in my previous post.

Here's one possible way if we make the following assumptions:

1. Each female gives birth to exactly 3 males and 3 females 60 years after she is born (but does not give birth again).

2. Elephants live exactly 100 years.


Let the number Kn be the number of elephants that are born in the nth generation, we have

K0=2 (since we start off with a single male and female)
K1=6
K2=18
K3=54
k4=162
.
.
.Kn=2*(3^n).

Can you see why we have the above? The 1st generation will have 6 children (3 males, 3 females) by assumption 1. The three girls in this first generation will each give birth to another 6 elephants each for a number of 18 (notice that this is 2*(3^2). And the 9 females in this next generation will each give birth to 6 elephants, for a number of 54 in the 3rd generation (notice that this is 2*(3^3)).

I'm going to assume that you can see why we have Kn=2*(3^n).

Now let us ask the following question:

How many years will it takes untill 15,000,000 elephants have been born (note: this does not mean there are currently 15,000,000 elephants in the population, as were ignoring all the elephants that have died)?

To find this we consider summing up terms from consective generations of elephants starting from K0 untill we get to 15,000,000. That is we want to find 'n' such that

15,000,000=K0 +K1 +K2 +.....+Kn.

Since Kn has the form Kn=2*(3^n), we can condense the above summation as

15,000,000 = (3^(n+1) -1), which can be converted to 15,000,001=3^(n+1).

Taking the logorithm of both sides gives us Log(15,000,001)=(n+1)Log(3), which can easily be rearringed as n=Log(15,000,001)/(Log(3) -1=14.04

If we approximate this to 14 (after all you can't have 14.04 generations now can you), then this means we need approximately 14 generations for 15,000,000 elephants to have been born.

Since a new generation is born every 60 years (since an elephant gives birth 60 years after she is born by assumption 1). This means it will have taken 60*14=840 years for their to be 15,000,000 elephants born.

Notice how 840 is fairly close to your answer.

Of course what we really want to know is how long will it will take for their to be a population of 15,000,000 elephants, therefore if we assume that 15,000,000 have been born in total over the 840 years, we need to ask ourselves how many have died.


By assumption 1, elephants live exactly 100 years so cleary the 2 elephants in the K0 generation are dead. To find the number L such that every elephant in generations K0, K1, K2,....KL are dead, but that the elephants in the K(L+1) generation are alive, we need only solve the following (can you see why)

840 -L*60=100.

The value for L which solves this is L=12.33... (this can easily be seen by rearranging variables).

Hence we take L=12 since all the elephants born in the 13th generation will only be 60 years, and hence still alive (this follows from the fact that 840 -13*60=60years).

We can now easily deduce how many elephants have died. Its just

2 + 6 +18 +54 +162 +....1,062,882=1,594,322. Hence at 840 years, there will be approx 15,000,000 -1,600,000 =13.4 million elephants.

Since we made the assumption that elephants are only born every 60 years we can't finish this problem with assumption 1 still in tact, however if we now remove that assumption and assume that the next generation of elephants (the 15 generation) are born with a uniform probability distribution over the next 30-90 year interval, then we can calculate the time needed for the 1.6 million needed with the following:

The elephants born in the 15th generation will be 2*(3^15)=28,697,814, which will occur entirelly over the next 90 years (but none will be born in the first 30 years).

Since we are assuming that these births occur uniformly over the 30-90 year period, we can calculate the time needed for the first 1.6 million to arrive by solving for x below (can you see why)

1,600,000/(28,697,814)=x/(90 -30), which has solution x=3.34 years

Hence it should taken approximately 840 +3.34 =843 years for 15,000,000 million elephants to be in the population.


Title: Re: Frisky elephants problem
Post by BenVitale on Feb 3rd, 2008, 11:46pm
Towr,
out of curiosity, code returned 842, can you explain what you did please?

Title: Re: Frisky elephants problem
Post by towr on Feb 4th, 2008, 5:56am

on 02/03/08 at 23:46:40, BenVitale wrote:
Towr,
out of curiosity, code returned 842, can you explain what you did please?
I just kept track of the number of elephants in each age group.
Each next year, the oldest group (age 100) die.
All other age groups move up one year.
The age groups 30-90 get 1/20 child each (1/10 for each pair, over 60 years that's 6 per pair), which makes up the new first-years.
Repeat until the total adds to 15 million.

Title: Re: Frisky elephants problem
Post by BenVitale on Feb 4th, 2008, 8:59am
What do you think of the above approach to the solution? Could anyone please tell me?

Title: Re: Frisky elephants problem
Post by BenVitale on Feb 4th, 2008, 9:25am
Towr,

Your answer is 842. My answer is around 873 years (about 30 years more).

"Since we are assuming that these births occure uniformly over the 30-90 year period, we can calculate the time needed for the first 1.6 million to arrive by solving for x below


1,600,000/(28,697,814)=x/(90 -30), which has solution x=3.34 years"

Okay my mistake is here at the end. I forgot to add in the extra 30 year period where we have no elephant births at all.

Hence the answer is 843 +30=873 years

Your thoughts, please.

Title: Re: Frisky elephants problem
Post by towr on Feb 4th, 2008, 9:38am
Hmm.. I've run a more detailed simulation. treating male and female elephants seperately and under the assumption they need to be paired off neatly to reproduce.
And I get the following results:
Starting with a random population of elephants, 415 out of 1000 reach 15 million (the rest die out; obviously half would where the first two are the same gender)

For the ones that reach 15 million, I get a mean of 915.79 years until 15 million is reach, and a whopping 3268.35 57.17 years for the standard deviation.
[edit]Things look much worse when you forget to take the squareroot.. 57 years deviation isn't too bad.[/edit]

Title: Re: Frisky elephants problem
Post by BenVitale on Feb 4th, 2008, 1:57pm
I still don't understand how you get 6 babies per 100 pairs. Don't you mean 6 babies per 1 pair per 100 years? Or 10 babies per 100 pairs per year.

Title: Re: Frisky elephants problem
Post by towr on Feb 4th, 2008, 2:14pm

on 02/04/08 at 13:57:27, BenVitale wrote:
I still don't understand how you get 6 babies per 100 pairs.
Where did I say that?
[edit]Oh wait, I found where; waaaaaay back
"3% reproduction rate, 6 babies per 100 pairs of elephants"

It's equivalent to say either 100 years * 1 pair or 1 pair * 100 years.[/edit]


Quote:
Don't you mean 6 babies per 1 pair per 100 years? Or 10 babies per 100 pairs per year.
Yes, 1/10 per pair per year for 60 reproductive years = 6 per pair per  reproductive life time = 6 per pair per lifetime.

Title: Re: Frisky elephants problem
Post by towr on Feb 4th, 2008, 2:18pm

on 02/04/08 at 09:25:20, BenVitale wrote:
Hence the answer is 843 +30=873 years

Your thoughts, please.
I don't think 30 years more or less matters a great deal; especially not when the standard deviation is three millennia. (And I suppose with an exponential growth such a large variation is only to be expected).

Title: Re: Frisky elephants problem
Post by towr on Feb 4th, 2008, 2:38pm

on 02/04/08 at 08:59:35, BenVitale wrote:
What do you think of the above approach to the solution? Could anyone please tell me?
Seems quite good. You could also have a look at what happens if the 6 babies of each generation are born a year sooner or later, to get an idea of how much of a difference it makes.


Title: Re: Frisky elephants problem
Post by BenVitale on Feb 4th, 2008, 3:20pm
Awesome, Towr, thanks for your input.

You wrote:

"Where did I say that?
[edit]Oh wait, I found where; waaaaaay back
"3% reproduction rate, 6 babies per 100 pairs of elephants"
It's equivalent to say either 100 years * 1 pair or 1 pair * 100 years.[/edit]"

Yeah I get that, but I had the feeling it might be assuming that the elephants can reproduce at any point in their lifetime, which is probably why it yeilds a number slightly smaller than mine.

Title: Re: Frisky elephants problem
Post by towr on Feb 5th, 2008, 1:54am

on 02/04/08 at 15:20:52, BenVitale wrote:
Yeah I get that, but I had the feeling it might be assuming that the elephants can reproduce at any point in their lifetime, which is probably why it yeilds a number slightly smaller than mine.
Well, as I said somewhere before; the whole calculation rest on treating the population as stable, i.e. each age group being equally represented. Which results in too many being born, but also far too many dying.

I think we can compensate for it; because assuming a growth rate x, we know the sizes of each age segment, and based on that we can adjust x.
I haven't had much success actually achieving this though. (Getting x to converge is a bit of a problem.)

Title: Re: Frisky elephants problem
Post by Grimbal on Feb 5th, 2008, 2:51am
I tried the following approximation:

I estimated the mean age of birth using a geometric average.
(35*45*55*65*75*85)^(1/6) = 57.43 years.
So 2 elephants become 6 in 57.43 years.
This translates to a growth rate of 1.0193, and at this rate you reach 15 million in 828 years.

Well, at least I get the correct order of magnitude.

Title: Re: Frisky elephants problem
Post by towr on Feb 5th, 2008, 8:58am
My last simulation, with 4310 out of 10000 pairs of elephants have a posterity reaching 15 million.
A mean of 918 years, and standard deviation 59.71 (and this time I didn't forget to take the squareroot)
A plot of the data below.

Title: Re: Frisky elephants problem
Post by Eigenray on Feb 5th, 2008, 2:12pm
There are a number of models one can use to get the asymptotic behavior:

Discrete: if B(n) is the number of females born in year 10n,

B(n+1) ?= B(n-4) + B(n-6) + B(n-8)
B(n+1) ?= [B(n-3) + B(n-4) + B(n-5) + B(n-6) + B(n-7) + B(n-8)]/2
B(n+1) ?= B(n-3) + B(n-5) + B(n-7)

These predict B(n) ~ Crn, where r = 1.176, 1.197, 1.211, respectively.  The population at year 10n would be P(n) ~ http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/sum.gifk=09 Crn-k.


Continuous: if B(t)dt is the number of females born between [t, t+dt],

B(t) ?= 1/20 http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/int.gift-90t-30 B(u)du.

This predicts B(t) ~ C*rt, where r = 1.019 [or B(10t) ~ 1.212n].  The population at year t would be P(t) ~ http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/int.gift-100t Crudu.

Which model is the most accurate?



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board