Urns with MCMC

From Computational Statistics Course Wiki
Jump to navigation Jump to search

An urn that contains five different types of balls that are drawn without replacement. Each time a ball is drawn, the probability of drawing a specific type of ball is proportional to the number of that type remaining and to a type-specific weight.

The experiment conducted was: draw from the urn until all balls have been drawn and record the order of colors produced. This experiment was carried out 50 independent times, producing urn_data.txt.

The initial counts in the urn are:

  • Red - 2
  • Blue - 4
  • Orange - 7
  • Purple - 3
  • Green - 5

The data consists of 50 lines that look like:

1 2 1 2 3 4 2 3 3 2 4 4 1 2 1 2 2 4 4 0 0

which says "For this trial, the draws went blue, orange, blue, orange, purple, ...."

Your job is to infer the values of the type-specific weights from the data by MCMC.

Each team must divide into three sub-teams, each of which has a specific task.

Sub-team 1: Produce a function that takes a set of weights and computes the likelihood of the entire data set given the weights.

Sub-team 2: Produce a function that takes the current set of weights and proposes a new set, returning the proposal and the corresponding ratio of q's.

Sub-team 3: Produce the logic that calls the two functions that will be supplied by the other sub-teams to carry out the MCMC. This will look like: For some number of steps,

  • propose a new set of proportions given the current ones
  • evaluate the likelihood of the data given the new proposal and combine with the q-ratio to produce alpha, and accept the proposal with probability alpha.
  • record the new values of the proportions used and the new likelihood.

Plot the trajectories of the proportions and the likelihood over the course of the steps.