# Bayesian Statistics Question

#### MegaMan

##### New Member

My current state is that I am clueless and have no idea what to do with it. Could somebody provide me some knowledge of how to start with this?

Last edited:

Looks tough!

Last edited:

#### Dason

It's not too bad actually. But it would be nice to see some work first...

#### MegaMan

##### New Member
Well I am trying to read up on it a bit but it's difficult..

#### Dason

Well tell us what you do know about for this problem. For instance what do you know about getting random samples from arbitrary distributions? Do you know what a Markov Chain random sampler is or how to program one? If you had a random sample from that distribution would you know how to compute the monte carlo estimate of the integral?

#### MegaMan

##### New Member
I have 0 knowledge at the moment, going to do some more reading. If there is anything that you can help with (hints etc), would appreciate this.

#### Dason

It's hard to give hints when we don't know which part you're stuck on. What exactly are you trying to do at the moment?

#### MegaMan

##### New Member
Could you tell me for example, what the easiest approach would be for this density function?

#### Dason

What different ways do you know to obtain a sample from a distribution?

#### MegaMan

##### New Member
Well I know how to do rejection sampling I think, but can I sample from the gamma part of it only and ignore the other part of the function?

#### Dason

What do you mean? Use the gamma proportional to x^4*exp(-3x) as your proposed density?

#### MegaMan

##### New Member
Yes, where alpha = 5, and beta = 3, is that plausible?

#### Dason

As long as you make sure that the density of that gamma is always greater than the density you're trying to sample from then you're ok. You'll need to prove to yourself at least that this is the case. (But you might even want to multiply the desired density by a constant so that you aren't always rejecting your proposed point).

#### MegaMan

##### New Member
I don't really understand, do I need to treat the other part of the density function as a uniform?

I was saying that the density of that gamma IS the density to sample from.. i.e. proposal density

#### Fanky

##### New Member
I would choose a density function which is always greater than the density you're trying to sample from. The term exp(-3x)*(1- exp(-2x))^7 is always smaller than 1. So, you can take g(x) = x^4. I am not sure. What do you think, Dason?

#### Dason

You propose x^4 over the positive real line? How would that work exactly?

#### Fanky

##### New Member
Ok, to apply the rejection method it must be a function whose indefinite integral is known analytically and is also analytically invertible (see Numerical Recipes, Press et al. p. 295). I plotted the function from 0 to 10 and integrated it. The proportional constant is 15.42493. Then the area under the density function is 1. There is only very few contribution to the area, if x is greater 10. So, I thought to regard only the interval 0 to 10.

#### MegaMan

##### New Member
I don't think that's what I have to do since part of the density function is a gamma density. But still not sure what to do with the other part of the function.

#### Fanky

##### New Member
So, you can take g(x) = a*x^4*exp(-3x) as upper function. It's always greater than f(x). But you also need rejection sampling for the gamma density. The comparison function is then of the form h(x) = c0/(1 + (x - x0)^2/a0^2). Then you can sample x = a0 * tan(pi*U) + x0 where U is a uniform deviate between 0 and 1. You must choose the values of a0, b0 and c0 such that h(x) is everywhere greater than f(x). I read this in Numerical Recipes on p.296.

#### BGM

##### TS Contributor
Another possibility is that you can add up 5 i.i.d exponential(3) random variates to obtain one gamma (though it may not be very efficient)

The one fanky points out should be some how like using the Cauchy random variate as the proposal density. Anyway the main point of the proposal distribution is that it should have the similar shape with the target to increase the efficiency, and also it should be easy to simulate.

The one I am most interested here is the Markov Chain sampler though