A game is played at a computer, as follows:

There are two coins, one silver coin and one gold coin, in a box. The computer “shakes” the box, and then tells the player whether the two coins landed on the same side or not. At this point the player must guess whether the coins are both heads or both tails (if they landed on the same side), or which of the two coins, silver or gold, is head (if they landed on different sides).

Now, if the coins were both fair, the player would just guess. The problem is that each coin can be of three types: - Fair coin (lands on head 50% of the times) - Biased coin coming up head 25% of the times - Biased coin coming up 75% of the times

The player does not know the exact probabilities; he (or she) only knows that the coins are not necessarily fair.

The game is repeated nine times with all the possible coin combinations.

During one game session the coins are tossed 32 times. The goal of the player is to make as many correct guesses as possible.

Now, since this is a computer game, the sequence of results is predetermined. When I say that a coin comes up head 75% of the times, it means that the coin will be head 24 times out of 32 (again, the player does not know that, he only knows that the coins are not necessarily fair). Since the sequences are all predetermined, I can compare different players, as they will all go through the same sequences.

The problem has two parts.



My data is the sequence of coin tosses. In the following example: - the gold coin has 25% chance on landing oh head - the silver coin has a 50% chance of landing on head.

1: landing on head 0: landing on tail

Gold:  0,0,0,0,0,1,1,1,1,0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0


I would like to model what an ideal observer would do. The ideal observer would start the game with a beta prior and the update it at each coin toss. I would like to see the updating at each toss, and what’s the final posterior after 32 tosses.

Is Stan a good way of doing this? I looked at the Rate1 example from the book Bayesian Cognitive Modeling: A Practical Course (2014) by Michael Lee and Eric-Jan Wagenmakers:

// Inferring a Rate
data { 
  int<lower=1> n; 
  int<lower=0> k;
parameters {
 real<lower=0,upper=1> theta;
model {
  // Prior Distribution for Rate Theta
  theta ~ beta(1, 1);

  // Observed Counts
  k ~ binomial(n, theta);

In the book example k, the number of successes, is 5 and n is 10. The code calculates the posterior distribution centered at 0.5. In my case I would like to see how the prior is updated step by step.

Should I just hard-code it manually then, using a loop with a beta-binomial updating? And would that work considering I have two coins? I was thinking about calculating the beta-binomial distributions of the two coins separately and then comparing them at each step.

Another thing I would like to know is which initial prior (comparing different types of beta priors, or other kinds of priors) would yield the best score (out of a max of 32, when one is making the correct decision at each turn).



My data is the player’s actual choices. For example, the following is a list of a subject’s choices in the case we considered above, according to the following code:

The coins landed on the same side, the subject bets on heads: 1 The coins landed on the same side, the subject bets on tails: 0 The coins landed on the opposite side, the subject bets the gold is head: 1 The coins landed on the opposite side, the subject bets the silver is head: 0

The line after the subject's choices shows his score: 1 if he guessed right, 0 if he guessed wrong

Gold:  0,0,0,0,0,1,1,1,1,0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0
Guess: 0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,0,1,1,0,0,1,1,1,0,1,0
Score: 1,0,1,1,1,0,0,0,0,0,0,1,1,0,0,0,1,0,1,1,0,1,1,0,1,1,0,0,0,1,0,1


I would like to reverse engineer the process: given the choice, what was the player prior? How did it change through the trials, and is the player biased toward the silver of gold coin?

Any ideas in setting this up?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.