Hi folks,

I have a 2D bimodal posterior distribution and I’m trying to sample from this posterior.

(After reading few comments/feedback, I figured out the NUTS/HMC cannot sample from both modes and there is a problem in jumping from one mode to another which can be related to energy barrier… I believe i need to implement the other methods like parallel tempering in this regard OR one empirical solution is manually restarting the generation from other start point, hoping to get stuck at the other minimum)

With all that being said, I’d appreciate it if you could let me know whether I’m doing something wrong based on Stan format or not.

I used 8 chains and i want to have 8 different initial values for each of them.

BUT base on the figures, it looks all of them start from one point…I checked out the warm up samples and it confirms that all starts from similar value.

For example: How can i tell it to be initialized from an exact point like x1 = -2, x2 = 6?

I’d highly appreciate your help.

Here is my Stan and Matlab code:

```
> data{
> vector[2] mu;
> matrix[2, 2] Sigma;
> }
> parameters {
> vector[2] x;
> }
> transformed parameters {
> real g = 5 - x[2] -0.5*(x[1] - 0.1)^2;
> }
> model {
> //prior
> x ~ multi_normal(mu, Sigma);
> //likelihood
> target += normal_lpdf(g | 0, 0.15);
> if (g > 0)
> target += negative_infinity();
> else
> target += -normal_lcdf(0 | 0, 0.15);
> }
```

[edit: escaped Stan code]

Matlab code:

%%–Initialize chains with different inits using structs

init(1) = struct(‘x’,7ones(1,2));ones(1,2));

init(2) = struct(‘x’,6

init(3) = struct(‘x’,5ones(1,2));ones(1,2));

init(4) = struct(‘x’,4

init(5) = struct(‘x’,[-5 5].*ones(1,2));

init(6) = struct(‘x’,[-2 7].*ones(1,2));

init(7) = struct(‘x’,[-1 5].ones(1,2));ones(1,2));

init(8) = struct(‘x’,8params = struct(‘file’,‘TruncBimodal.stan’,‘data’,dat,‘chains’,8,…

‘iter’,10000,‘warmup’,1000,‘algorithm’,‘NUTS’,‘inc_warmup’,…

true,‘verbose’,true);

fit = stan(params,‘chains’,8,‘init’,init);

I attached the plot to show how it looks like.

Thank you in advance for your time and consideration!

Hamed