jakeret / abcpmc Goto Github PK
View Code? Open in Web Editor NEWApproximate Bayesian Computation Population Monte Carlo
License: GNU General Public License v3.0
Approximate Bayesian Computation Population Monte Carlo
License: GNU General Public License v3.0
Hello,
I encountered inconsistent behaviour for random processes within
the generator when using multiprocessing for abcpmc.Sampler(..., postfn = testrand, ... )
`
def testrand():
import random
import numpy as np
random.randrange(1000) # Is random
np.random.randint(1000, size=1) # yields same results for every process
np.random.poisson(1000,10) # yields same results for every process
return 0
`
One possible workaround is to use random to set a random seed for numpy within the function:
seed = random.randrange(4294967295)
np.random.seed(seed=seed)
however this is bulky and might confuse some users that might not know about this behaviour.
Could you please consider adapting abcpmc to also exhibit the random behavior for numpy.random?
Thanks
jakgel
When the code "eps.eps = np.percentile(pool.dists, alpha, axis=0) " raised a exception, this might because pool.dists is null.
My solution is adding the following code:
res = self.mapFunc(wrapper, range(self.N))
res_thetas=copy.deepcopy(res)
res_dists=copy.deepcopy(res)
res_cnts=copy.deepcopy(res)
#res = self.mapFunc(wrapper, range(self.N))
thetas = np.array([theta for (theta, _, _) in res_thetas])
print('thetas is : {0}'.format(thetas))
dists = np.array([dist for (_, dist, _) in res_dists])
print('dists is : {0}'.format(dists))
cnts = np.sum([cnt for (_, _, cnt) in res_cnts])
print('cnts is : {0}'.format(cnts))
ws = np.ones(self.N) / self.N
the same for "res = self.mapFunc(particleProposal, range(self.N))"
First of all, thank you for your excellent job. However, I've run into two issues. Could you kindly help me in solving them?
(1) I tried three samples many times, and found in the loop of "for pool in sampler.sample(prior, eps)", pool.dists was always null, therefore resulting in np.percentile(pool.dists, alpha, axis=0) raise an error. So I wonder whether it is normal, or it has something with multi-thread programming ?
(2)If I have three distance functions, should I specify three eps (thresholds)? I found in "Example of using two distance + thresholds in one ABC sampling run" , distance function returns two values within a list object, and eps_start is set to [1.0, 1.0]. I guess if I have three distance functions, I have to specify three eps_start like [1.0,1.0,1.0].I noticed that eps is updated in the code "eps.eps = np.percentile(pool.dists, alpha, axis=0) ", the three eps are synchronously updated with same scaling control factor-alpha. If I want to specify three various scaling control factor, I should update the eps.eps object?
Thank you.
I'd like to try the OLCMParticleProposal()
class, but it's not clear to me how to implement it. I looked around but couldn't find any examples of this.
Could you please add one?
I've been using this package for a few days (thank you BTW!) and it works great. One issue I have is that it seems to get stuck forever if I use >20 particles, trying to find solutions with distances below the threshold for all of them:
Is there a way to break out of this if enough time has elapsed? Is this even a good idea?
Is it possible to update the distance metric between iterations? My motivation for this is the case where one has multiple summary statistics entering the distance metric, but it is not obvious how to weight them. A reasonable choice would involve the covariance matrix of the summary statistics, but this is not known in advance. I'd like to use e.g. the sample covariance of the summary statistics in the previous iteration to weight them in the distance metric.
Dear Joel,
Hope you are fine.
I am a graduate student at University of Central Florida, USA. I am working on the ABC PMC toolbox.
At first I am trying to work with the examples 2D gauss, Multi distance, and the toy model. Unfortunately, I am unable to run those examples.
Every time I call the pool using the function ‘pools = sample(T, eps, sigma/sqrt(n))’ the program stuck in an infinite loop. It does not give any solution and runs indefinitely.
It is happening for all the three example model.
Can you please help me to solve this problem?
Regards,
Sheik Mohammad Mohiuddin
Graduate Student, UCF
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.