Tips on model structure for "the number guessing game"?

Outside of tutorials, I’m somewhat new to pymc3 so as a toy exercise, I’m interested in modeling the “number guessing game” in pymc3. For example, one person knows the “true number” and the other guesses, with a response of “too high” or “too low”.

I am following the theory found in this paper.

I certainly can model the unknown number as a DiscreteUniform (theta).

I’m just struggling to figure out how to model the discrete “too high/too low” decision concept.

The coal mining tutorial does have a decision point, but that’s a single decision for all observations, whereas here, a decision is made every observation (guess).

1 Like

Hmmm, I guess you can model it as a Bernoulli, with 0 being too low, and 1 being too high. I would model the guess as a Uniform (theta_1), and use the p=tt.switch(theta_1 > theta, 0, 1) as the p for the Bernoulli.
So the logic here is that, the latent guess is also a DiscreteUniform number (but use Uniform as continuous variable are easier to handle in PyMC3), and the guess-er compare this latent number with the true number (unknown to the guess-er, so also latent) and make a probabilistic judgement:

with pm.Model() as m:
    true_num = pm.Uniform('theta0', ...)
    guess_num = pm.Uniform('theta1', ...)
    true_num_obs = pm.Normal('true_num', mu=true_num, sd=k, observed=true_number) 
    # k here is the internal uncertainty of the guess-er, not sure what is 
    # the best way to model this
    guess = pm.Bernoulli('guess', 
                         p=tt.switch(guess_num > true_num, 0, 1), 
                         observed=response=='too high')
1 Like

The linked paper seems to associate a cost \alpha for guessing too high vs. too low, and then gets into some analysis for how to also model the cost of the game going forwards (i.e., now that you’ve made this one guess, what’s the expected cost of continuing to play the game?)

I’ll have to think more about how to model this, but it looks hard to me! In particular, the paper poses this as an open problem to find \gamma, and whether the functional form is the correct one, I think?

Yeah to start I was skipping the risk side and looking to just model the guesser’s current uncertainty in the unknown number after N guesses where their feedback/observation is just “too high” or “too low”. I am envisioning seeing that uniform tighten up around a number as N increases.

Cool. I like the idea of the Bernoulli and the switch. This looks cleaner than what I was thinking. I was considering a custom likelihood function that is a sigmoid that is either standard or flipped depending on the “too high” “too low” response.

For example, if true_number= “3” and guess=“7”, then likelihood(response=“high” | true_number=“3”, guess=“7”) ~ 1.0. And likelihood(response=“low” | true_number=“3”, guess=“7”) ~ 0.0.

However that approach seems very engineered to me so I like the Bernoulli idea. I’ll try it out and report back.

1 Like