I love your work and own a hard copy of Think Bayes 2! I know you got the cell counting example from another fantastic content creator. I have been pondering inferred vs. known error in my models and I think that the pymc cell counting model can be improved for posterity. Mainly, I think that there are a bunch of parameters that are inferred in pymc3 that should be fixed. For example:
with pm.Model() as model:
yeast_conc = pm.Normal("yeast conc",
mu=2 * billion, sd=0.4 * billion)
shaker1_vol = pm.Normal("shaker1 vol",
mu=9.0, sd=0.05)
shaker2_vol = pm.Normal("shaker2 vol",
mu=9.0, sd=0.05)
shaker3_vol = pm.Normal("shaker3 vol",
mu=9.0, sd=0.05)
should be:
import theano
shaker_vol_mu = theano.shared(9.0)
shaker_vol_sd = theano.shared(0.05)
with pm.Model() as model:
yeast_conc = pm.Normal("yeast conc",
mu=2 * billion, sd=0.4 * billion)
shaker1_vol = pm.Normal("shaker1 vol",
mu=shaker_vol_mu, sd=shaker_vol_sd)
shaker2_vol = pm.Normal("shaker2 vol",
mu=shaker_vol_mu, sd=shaker_vol_sd)
shaker3_vol = pm.Normal("shaker3 vol",
mu=shaker_vol_mu, sd=shaker_vol_sd)
I'm interpreting the mean and sd of yeast conc as prior values to be inferred, and the mean and sd of shaker volumes as fixed values based on information from outside of the model inference (e.g., the values listed on the package of a pipette or something). I think this is also consistent with ABC portion of the analysis present just after. Other lines of code that would be added include the following:
shaker_transfer_mu = theano.shared(1.0)
shaker_transfer_sd = theano.shared(0.01)
chamber_vol_mu = theano.shared(0.0001)
chamber_vol_sd = theano.shared(0.0001/20)
associated pm.Normal()
calls would be updated.
My motivation for writing is the amount of time it took for me to figure out how and when to specify fixed vs. inferred parameter values in my models. Thanks!