120 likes | 233 Views
Psychology 290 Special Topics Study Course: Advanced Meta-analysis. April 2 , 2014. The plan for today. A digression on random number generation. Markov chain methods for sampling from arbitrary distributions. Uniform random numbers.
E N D
Psychology 290Special Topics Study Course: Advanced Meta-analysis April 2, 2014
The plan for today • A digression on random number generation. • Markov chain methods for sampling from arbitrary distributions.
Uniform random numbers • The root of all random number generation is the uniform distribution. • Historically, most uniform RNGs used some variant of the linear congruential algorithm. • Xn+1 = (aXn + c) mod m. • Examples in R.
But we’re interested in non-uniform random numbers • Convert uniforms: • Inverse cdf • Acceptance / rejection • Clever algorithms for specific distributions • Examples in R
Inverse CDF • Generate uniform values • Use the quantile function (i.e., the inverse CDF function) to change uniforms to target.
Clever approaches • Distribution specific. • Examples: • Polar method for normals • Squared normals for chi square
Acceptance / Rejection • You want to generate RVs from f(x). • You can easily generate g(x), for which the maximum value of f(x) / g(x) is not too different from 1. • Algorithm: • Generate g(x) • Accept it if U(0,1) < f(x)/(c g(x))
Problems with acceptance / rejection • Inefficient • Sometimes there isn’t an easy g(x) with reasonable c.
Markov chain methods • Markov chain methods are ways to sample from arbitrary distributions using a random walk approach. • Why is this relevant to Bayesian methods?
The Metropolis-Hastings algorithm • Let h(x) be an unnormalized density • Starting at x, propose a move to y that has conditional probability given x denoted q(x,.) . • Let r(x,y) = h(y)q(y,x)/(h(x)q(x,y)). • Accept the proposed value with probability min(1,r(x,y)) • Illustration in R.
Next time • Introducing Bayesian methods. • Bayesian analysis