The assignment questions are given below. There are three parts. You can find any files you need in this repo. Please push your answers to the version of this repo that was created when you accepted the classroom invite on Github classroom. You can either submit one file for each, or a single file that contains all the answers (either a pdf or a .md file, complete with images). The deadline is April 29th.
As an aside, this .md file was created using a nice github app called TeXify (https://github.com/apps/texify), a GitHub app that looks in your pushes for files with extension *.tex.md and turns them into rendered .md files.
Use the Urn model starting with 2 red balls of weight 1, and one black (mutation) ball of weight w.
Draw balls until you have 10 non-black balls. Implement the rejection method to answer the following questions:
Assuming a Uniform[0,20] prior for the weight of the black ball, if all non-black balls are the same color at the end, what is the posterior distribution of the weight of the black ball?
Assuming a Uniform[0,20] prior for the weight of the black ball, if we observe exactly 2 non-black colors at the end, what is the posterior distribution of the weight of the black ball?
Repeat part 1 of the assignment, but this time just to find the posterior distribution for the weight of the black ball if we observe just one non-black color at the end.
But this time sample the weights, using an
distribution, rather than a
distribution.
We are now doing importance sampling, so if you accept the value of , because the simulated urn had just one non-black color in it, then you need to add a mass of
to the posterior distribution of
(whereas we used to add a mass of 1).
Remember to truncate the expo at 20, to match the domain of the prior dsistribution (and to allow for thius when you evaluate
.
Compare the efficiency of this algorithm to that pf the pure rejection method you used in part 1. (How many iterations are required to get 1000 accepted values, say?)
Many tissues contain 2 (or more) cell-types.
Many tissues contain 2 (or more) cell-types. An investigator wants a way of testing whether each of 2 cell types in a given tissue is homogeneously distributed (in space). So:
: cell types are homogeneously (randomly) arranged
: cell types are not homogeneously arranged (i.e. they are clustered in some fashion).
Your job is to come up with such a test, using Monte Carlo methods.