MCB111: Mathematics in Biology (Fall 2023)

week 00:

Sampling from a probability distribution


Present all your reasoning, derivations, plots and code as part of the homework. Imagine that you are writing a short paper for anyone to be able to understand. A jupyter notebook if you are working in Python is not required, but highly recommended.


This is mostly a computational question, you get familiar with some coding, and also on how to sample from any probability distribution.


Bacteria often form aggregates of cells. Aggregates seem to have more antibiotic tolerance than not aggregated bacterial cells. It is important to study conditions that could deplete aggregation as a potential tool to fight bacterial infections.

For a collection of bacterial cell (P. arruginosa to be more specific) aggregation is a stochastic process that happens with probability \(p\). Someone in your lab has measured \(p\) under one set of default host condition. The data of those measurements are here: data_default.

You come new to the lab, and your job is to test a different set of conditions. These experiments are involved. Each time, you need to set a large number of colonies, wait 1 day, and determine the fraction of those that has aggregated. Then, you need to repeat the experiment.

Q3 (extra credit)

Use rejection sampling instead of the inverse method to approach Q2.

In rejection sampling, the rejecting distribution is arbitrary. Here, since the random variable is a probability \(p\), which ranges between \([0,1]\) it makes sense to use the Uniform distribution as \(g(x) = 1\).

To apply rejection sampling, then you only need to setup the constant \(M\) such that for all \(p\in [0,1]\), \(p(p) \leq M\).

Note that in this case \(p(p)\) takes sometimes values larger than 1.


Bacterial cells do aggregate and form colonies with complicated spatial organization. The possible effect of bacterial aggregation on antibiotic resistance is an active subject of research. See an example here. The data in this homework is completely made up.