Code Monkey home page Code Monkey logo

Comments (5)

AllenDowney avatar AllenDowney commented on June 13, 2024

Hi Greg. Thanks for this suggestion. Based on my mental model of how PyMC works, I am not convinced yet that these changes will make a difference, but I might be mistaken. Have you run a minimal example with and without this change, and are the results actually different?

from thinkbayes2.

gbrunkhorst avatar gbrunkhorst commented on June 13, 2024

Allen - I worked this example further and got a tip from Christian Luhmann on Discourse and my thoughts are now laid out in this notebook. I think you will be able to see what I'm thinking by scanning the visuals. I ran my analysis on a simplified model, but following the pattern, I think that this code:

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.tensor as tt
rand_stream = tt.random.utils.RandomStream()

with pm.Model() as model:
    yeast_conc = pm.Normal("yeast conc", 
                           mu=2 * billion, sd=0.4 * billion)

    shaker1_vol = pm.Deterministic("shaker1 vol", 
                                rand_stream.normal(9.0, 0.05))
    shaker2_vol = pm.Deterministic("shaker2 vol", 
                                rand_stream.normal(9.0, 0.05))
    shaker3_vol = pm.Deterministic("shaker3 vol", 
                                rand_stream.normal(9.0, 0.05))

if the intent is for the shaker volumes to be fixed distributions (i.e., regardless of the observed data). Let me know if I can help develop this idea further.

Greg

from thinkbayes2.

AllenDowney avatar AllenDowney commented on June 13, 2024

Hi Greg,

I think I see the distinction you are making: in the first case, the model specifies a prior distribution for shaker1_vol (for example) and generates samples from its posterior distribution. In the second case, the distribution of shaker1_vol is considered known and does not get updated based on the data.

If I'm interpreting that correctly, I think the first model is what I want to use. It might seem strange that the data should change our opinion about the volumes of the shakers, but it might help to think of it this way: "Before seeing the data, I knew that the actual volume in the shakers could vary. After seeing the data, I have some information about where in the range of variation the volumes happened to fall during this particular experiment." For example, in a sample where yeast_conc is actually low, and the measurements are relatively high, I would suspect that the volumes were on the high side.

Allen

from thinkbayes2.

gbrunkhorst avatar gbrunkhorst commented on June 13, 2024

Yes, you see the distinction I'm trying to make! Thank you. I'll close this issue and leave my code on Discord for posterity. In my work in environmental engineering, the second model is more common (e.g., the laboratory reported the concentration is x, and their qaqc program says they are accurate to +/- s). But I can see your point and it depends on the scientist. The beauty of open science is that the assumptions are transparent!

from thinkbayes2.

AllenDowney avatar AllenDowney commented on June 13, 2024

All good. Thanks!

from thinkbayes2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.