Question: Please provide R code for the below questions: Using the accept-reject algorithm, generate observations from the binomial distribution as target distribution and the uniform distribution

Please provide R code for the below questions:

  1. Using the "accept-reject" algorithm, generate observations from the binomial distribution as target distribution and the uniform distribution as proposal distribution. Reverse the roles and carry out the same simulation and note the differences.
  2. The Gibbs sampling algorithm is an iterative algorithm for sampling from a multivariate joint distribution via conditioning on each marginal distribution in sequence. This is useful if it is difficult to get at each marginal distribution directly via integration (or summation). To simulate a distribution f we can construct a sequence of random variables (Markov chain) x(1),...x(n) such that the stationary distribution v ~ f(x) . Consider the bivariate normal distribution x = (x1,x2)'with mean =(7,9)'and variance/covariance matrix 2*2 matrix [5,4,4,10] . To use Gibbs sampler, we need the conditional distributions. From univariate theory we know the conditional distributions of a bivariate are themselves normal. Implement the Gibbs sampler to simulate this bivariate normal distribution, and visualize each estimated marginal distribution.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!