Question on running multiple chains simultaneously

20 views
Skip to first unread message

larryh...@gmail.com

unread,
Feb 6, 2017, 10:29:15 PM2/6/17
to QUESO-users mailing list
To run multiple chains simultaneously, I modified the input file so that:

env_numSubEnvironments = 4
env_seed = -1

Depends on the manual, I guess this is all I need to do right? Then I run

mpirun -np 4 simple_sip_example example.inp
Then I got result of 4 chains. I'd like to know if this is the correct way to run multiple chains?
When I check the output of these chains, there are 2 chains were not very correct. For example, for 5 dimensional rosenbrock function, I should get the result converge at [1 1 1 1 1] in each chain, but there were two chains finally converged far from correct value. I tried to run the program for 1 chain multiple times, I always got reasonable result.
My question is, is there any possibility that run multiple chains simultaneously will influence the result? Or my way of run multiple chains is not very correct?
Ps: I post this question through my cell phone, please forgive me if the format doesn't look good.

Thank you very much!
Best regards,
Han

Damon McDougall

unread,
Feb 7, 2017, 9:02:31 AM2/7/17
to larryh...@gmail.com, QUESO-users mailing list


On Mon, 6 Feb 2017, at 21:29, larryh...@gmail.com wrote:
> To run multiple chains simultaneously, I modified the input file so that:
>
> env_numSubEnvironments = 4
> env_seed = -1
>
> Depends on the manual, I guess this is all I need to do right? Then I run
>
> mpirun -np 4 simple_sip_example example.inp
> Then I got result of 4 chains. I'd like to know if this is the correct
> way to run multiple chains?

You'll get four chains as output, and each chain owns a single
processor.

> When I check the output of these chains, there are 2 chains were not
> very correct. For example, for 5 dimensional rosenbrock function, I
> should get the result converge at [1 1 1 1 1] in each chain, but there
> were two chains finally converged far from correct value. I tried to run
> the program for 1 chain multiple times, I always got reasonable result.
> My question is, is there any possibility that run multiple chains
> simultaneously will influence the result? Or my way of run multiple
> chains is not very correct?

Multiple chains should not affect the result.

A couple of follow-up questions:

1. Are you optimising the cost function before sampling?
2. If the answer to 1. is 'no', then where are you starting the chain?
3. What is your prior?

--
Damon McDougall
http://dmcdougall.co.uk
Institute for Computational Engineering Sciences
201 E. 24th St., Stop C0200
The University of Texas at Austin
Austin, TX 78712-1229

Damon McDougall

unread,
Feb 8, 2017, 11:20:20 PM2/8/17
to Han Lu, queso...@googlegroups.com
Let's keep queso-users in the cc list with a 'reply-all' so others can
chime in if they want to.

On Wed, 8 Feb 2017, at 20:22, Han Lu wrote:
> Hi Damon,
>
> Thank you for your reply, and sorry for the late reply.
> 1. I suppose the cost function you said is the Rosen-Brock function. What
> do you mean by optimizing it? I just used this function:
> [image: Inline image 1]

I presume you mean to say that this is your log-likelihood? If so, then
your likelihood is proportional to exp(-f). This gets multiplied by the
prior distribution to make the posterior (up to a constant of
proportionality). The cost-function is -log(posterior). QUESO has the
capability to optimise this function and use the result of the
optimisation to start the Markov chain Monte Carlo process. See here
for an example on optimising before sampling:
https://github.com/libqueso/queso/blob/hotfix-0.56.2/test/test_optimizer/test_seedwithmap_fd.C#L73

> 2. I started the chain with initial value [5 5 5 5 5] for no particular
> reason, it can be other values.

Yes that's true. The further you start away from stationarity, the
longer it'll take to converge. I was just curious as to how far away
from stationarity you started. If you're optimising before sampling,
then this point isn't used to initialise the chain, it's used to
initialise the optimiser.

> 3. Did you mean the prior covariance matrix? I set it to be a diagonal
> matrix and the elements on the diagonal are just some values I randomly
> chose(sorry I don't have the code currently). I am also confused about
> how
> to set a proper covariance matrix, because I found out that the result
> was
> obviously effected by the cov matrix. The question here is with the same
> parameters, I cant have all the chains correct when running them
> simultaneously, but I can get good result with one chain each time I run
> it.

If your prior is Gaussian, then yes I'm talking about the prior
covariance matrix (and prior mean). Your prior could have some other
distribution, though.

Yes, different prior covariance matrices (and hence prior distribution)
yield different posteriors, so you'll get different results. In fact
assuming your log-likelihood is the Rosenbrock function any prior that
is not the Uniform distribution will give you a cost function that is
not the Rosenbrock function. And if you're giving the prior covariance
matrix small entries in some elements along the diagonal, it may be the
case that your posterior basically looks Gaussian in those directions.

To bring it back to your original question. Two chains versus one
shouldn't affect the converged result. How many samples are you running
for? If you start the chain at [1 1 1 1 1] does it stay there? If your
prior is Gaussian away from [1 1 1 1 1] then the converged result will
*not* be [1 1 1 1 1], it'll be whatever the posterior mode is (there
could be more than one).

>
> Thank you very much!
> Good night,
> Han
>
> Best regards,
> Han
> Email had 1 attachment:
> + image.png
> 14k (image/png)

larryh...@gmail.com

unread,
Feb 9, 2017, 5:41:59 PM2/9/17
to QUESO-users mailing list
Hi Damon,

Thank you very much.
I just found out that when I run a single chain, I didn't change the 'env_seed', and each time actually I was getting the same chain. I tested several times with different seeds, it seemed that the result couldn't converge to ideal value every time. So I guess there is no problem with running multiple chains simultaneously.
My another question is, how to set the proposal covariance matrix? I checked some papers about proposal distribution, I didn't find how to set this matrix. Do you have any advice?

Thanks,
Best regards,
Han

Damon McDougall

unread,
Feb 20, 2017, 1:54:11 PM2/20/17
to larryh...@gmail.com, QUESO-users mailing list
Hi Han,

On Thu, 9 Feb 2017, at 16:41, larryh...@gmail.com wrote:
> Hi Damon,
>
> Thank you very much.
> I just found out that when I run a single chain, I didn't change the
> 'env_seed', and each time actually I was getting the same chain. I tested
> several times with different seeds, it seemed that the result couldn't
> converge to ideal value every time. So I guess there is no problem with
> running multiple chains simultaneously.
> My another question is, how to set the proposal covariance matrix? I
> checked some papers about proposal distribution, I didn't find how to set
> this matrix. Do you have any advice?

This is something we ought to have a better default for so the user
doesn't have to concern themselves with it. That said, here's some
things to think about:

1. The proposal covariance matrix essentially dictates how for Random
Walk Metropolis is willing to 'jump' in state space to get the next
state in the Markov chain.

2. It's clear, then, that if it's too large, the proposal will be far
away from the current state. If the state is already in a
high-probability zone, jumping far away is likely to put the chain in a
low probability zone and get rejected. This is especially true for
Gaussians.

3. If it's too small, then, it's much more likely to get accepted. But
now there's a new problem: mixing. Mixing is the chains ability to
wander around the state space well. If it doesn't wander very well, it
can take a long time to get a good posterior mean calculation because
the samples are much more auto-correlated.

4. If you know something about how your posterior looks (maybe close to
Gaussian?), try to pick the proposal covariance to look like the inverse
of the Hessian at the MAP point. Of course, not all posteriors are
Gaussian.

There's no silver bullet, but hopefully this has shed some light on how
to select it. If your forward problem is cheap, play around with
scaling the proposal covaraince by a constant and look at what effect it
has on the resulting chain.
> --
> You received this message because you are subscribed to the Google Groups
> "QUESO-users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to queso-users...@googlegroups.com.
> Visit this group at https://groups.google.com/group/queso-users.
> For more options, visit https://groups.google.com/d/optout.

larryh...@gmail.com

unread,
Feb 22, 2017, 6:01:30 PM2/22/17
to QUESO-users mailing list, larryh...@gmail.com
Hi Damon:

Thank you for your detailed reply. I'll think about it.

Best regards,
Han
Reply all
Reply to author
Forward
0 new messages