A Dolphin Population Model
Build a model for a dolphin population over 150 years. Model Assumptions and Input:
• Dolphins live for an average of 35 years, with a standard deviation of σ = 5 years.
• Dolphins procreate starting at the age of 8 until death. They produce no more than 1 calf every 5 years (assuming gestation length is zero).
• No dolphins can procreate with another that share the same set of parents and must procreate with other dolphins that are within 10 years of their own age and of the opposite sex. Male and female calves are equally likely: P(male) = 1 – P(female) = 0.5.
• No new calves can be named the same as any other dolphin, dead or alive.
• Start with an initial population of 4 dolphins, two females and two males, all at the age of 0.
1. Use a webservice to make two data files with a unique name in each line, one for the males and the other the females. A good place to start:
Download lists of male and female names from the above source. Write a function that retrieves
~ 7,500 names for both the males and females and save them in two separate data files (usually, with the extension .dat). At the moment this website has ~100 names per page, which means you need to download 75 pages worth of names.
2. Use the name data files made in the above step, write a name generating function. You should use yield rather than return in this function so that each time it is called, it will return the next name. This function should take sex as an input parameter.
When you run out of unique names, you are allowed to add a middle name. The middle name can be a random string of ten letters. (No, we don’t care that much about middle names, not those for dolphins anyway!) You can do a quick calculation and convince yourself that, with middle names generated this way, the probability of having two dolphins with the same
name is extremely low.
3. Create a class Dolphins() that should include at least the following attributes: