Skip to content

Conversation

@ffinger
Copy link

@ffinger ffinger commented Apr 7, 2016

…eam to postfn

Flavio added 2 commits April 7, 2016 20:35
…of added so to consecutive threads that get seeded in consecutive seconds can not get the same seed by chance
Seed can not be bigger than a certain number. thus changed it.
@jakeret
Copy link
Owner

jakeret commented Apr 18, 2016

By using time the entire system becomes non-deterministic i.e. it will be impossible to reproduce the exact same result.

@ffinger
Copy link
Author

ffinger commented Apr 18, 2016

yes, I do agree. On the other hand I think it is quite important that the seed is not the same (1...N) in every calibration run. How about seeding the main process, drawing k random numbers (k=number of workers in the pool), which then serve to seed the generators of all workers? in this way the system is deterministic but still depends on the main seed, which can be changed.

also, I think it is very important to pass on the Random Stream to the postfn function, so that random numbers needed to compute the likelihood come from the same stream. otherwise they come from numpy.random, whose state random state (in Unix) is inherited from the main process, and thus the random numbers in the postfn function on different processes are identical.

@jakeret
Copy link
Owner

jakeret commented Apr 18, 2016

Ah, now I see the issue that the current reseeding causes. Creating the seeds in the main process is actually a good idea. I need to think about what happens when paralellizing with MPI but at the moment I think it could do the trick.

I would like to keep the function signature of postfn as simple as possible. One has the option to perturb numpy's seed using the passed theta values or time.

@ffinger
Copy link
Author

ffinger commented Apr 18, 2016

I would like to keep the function signature of postfn as simple as possible. One has the option to perturb numpy's seed using the passed theta values or time.

How about making random state an optional argument then?

@jakeret
Copy link
Owner

jakeret commented Apr 19, 2016

Do you see an other way to do this than wrapping the postfn-call in a try-except? This is not very elegant, in particular because in 99% of the applications it will fall in the except block

@ffinger
Copy link
Author

ffinger commented Apr 19, 2016

I do not have experience with this, but the inspect module might be an option. You can get the number of arguments a function takes as well as the names of kwargs.
http://stackoverflow.com/questions/4674875/python-function-parameter-count

@jakeret
Copy link
Owner

jakeret commented Apr 21, 2016

Inspecting the callable before the call to identify the number of params feels a bit like overkill and not very pythonic

@ffinger
Copy link
Author

ffinger commented Apr 21, 2016

right. maybe use a parameter that can be True or False when you setup the
sampler object? it can be False by default, so no random state object is
given to postfn, but if it is True you give one.

2016-04-21 10:23 GMT+02:00 jakeret [email protected]:

Inspecting the callable before the call to identify the number of params
feels a bit like overkill and not very pythonic


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#10 (comment)

Flavio added 2 commits April 21, 2016 15:58
…n the main process which creates seeds for the forked processes. also has a restart function. still using my implementation to be able to give the random state to postfn
@ffinger
Copy link
Author

ffinger commented Apr 21, 2016

I just implemented what I wrote in my last comment. Up to you if you like it and want to include it in your version. For my application it is necessary.

@jakeret
Copy link
Owner

jakeret commented Apr 22, 2016

Could you give me some information on your application so that I can understand why it's neccessary?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 91.571% when pulling 3bad250 on ffinger:master into bd4e22f on jakeret:master.

@ffinger
Copy link
Author

ffinger commented Apr 22, 2016

Because I am using it to calibrate a stochastic model (that means I make extensive use of random numbers in the model) and I would like to be able to control the rng state of the model too, otherwise the calibration is not reproducible.

@jakeret
Copy link
Owner

jakeret commented Apr 22, 2016

Can't you use the theta values passed to your function to seed the RandomState in your model?

@ffinger
Copy link
Author

ffinger commented Apr 22, 2016

You mean a seed depending on the parameter values? I don't get it.

2016-04-22 10:45 GMT+02:00 jakeret [email protected]:

Can't you use the theta values passed to your function to seed the
RandomState in your model?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#10 (comment)

@jakeret
Copy link
Owner

jakeret commented Apr 22, 2016

Exactly, e.g. define the seed to be the sum or product over all the parameters. In principle the proposed parameters all come from a reproducible rng stream. It's not perfect but simple

@ffinger
Copy link
Author

ffinger commented Apr 22, 2016

But then the seed is the same for a given parameter set. Not a good idea
for a stochastic model, where you want to have variability among different
runs of the same model with the same parameters.

2016-04-22 13:28 GMT+02:00 jakeret [email protected]:

Exactly, e.g. define the seed to be the sum or product over all the
parameters. In principle the proposed parameters all come from a
reproducible rng stream. It's not perfect but simple


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#10 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants