Material covered:
- Loops
- Functions
- Data Structures
- Randomness
- Numpy arrays
(python language)
Problem statement
A single amoeba sits in a pitri dish. Every 5 minutes one of twothings will happen to the amoeba:
1.    There is a chance that the amoeba dies- producing no offspring.
2.    If it does not die the amoeba splitsinto two amoebas.
make a function that simulates a single trial to calculate thelifespan of a colony of amoebas, given their chance of survival.Then, run that trial for some number of repeated trials(iterations).
To make this work, write the following functions. Test yourfunctions fully before moving to the next one. You do not have tofollow this order, but it is encouraged.
BUILD A PROGRAM USING THIS 4 STEPS.
1 - Calculate next generation
make a function that is passed the number of living amoebas, andthe odds of survival - then calculates how many amoebas are alivein the next generation. Each amoeba in the population has a randomchance of splitting, or dying. See the above random chance ofdividing, or dying. Calculate the number of amoeba in the newgeneration.
2 - Single Trial
built a function that executes a single trialof the amoeba experiment. A trial is to simulate up to 20generations of an amoeba colony. If there are no remaining amoebas,the function should exit without continuing calculating moregenerations.
This function should return a tuple that contains three piecesof data:
1.    The number of iterations that weresimulated.
2.    A boolean indicates if all the amoebasare dead before 20 generations.
3.    The final population.
3 - Repeat the trial
built a function that will repeat the trial function 1000 times,storing the output of the trial in numpy arrays. Print the reportfor these repeated trials. Your output should be to two decimalplaces.
Report on the percentage of colonies that did not survive (endwith 0 amoebas), and the average number of generations for failedcolonies. Finally, report on the average population size onsuccessful populations.
4 - Repeat trials with different survivalrates
Do many trials, using different survival rates. Start with a 50%survival rate, then report in intervals of 5 all the way up to 95%survival rate.
This piece can be in a function, but does not need to be.
Sample output - yours will vary in terms of numbers:
OUTPUT:
For survival odds 0.50:
  The amoebas did not survive 93.70% of the time.
  On failures, there were 2.83 generations onaverage.
  If the amoebas did survive, the average populationwas 14.10
For survival odds 0.55:
  The amoebas did not survive 80.10% of the time.
  On failures, there were 2.71 generations onaverage.
  If the amoebas did survive, the average populationwas 31.61
And so on, up to 95%