Code Monkey home page Code Monkey logo

abcpmc's People

Contributors

jakeret avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

abcpmc's Issues

Same seed in Multiprocessing for numpy

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

Solution for pool.dists =[]

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))"

Multi-distance functions and their thresholds updating

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.

How to use a different particle proposal?

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?

Break out if sampler gets stuck in while loop

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:

captura de pantalla de 2018-09-11 11-41-29

Is there a way to break out of this if enough time has elapsed? Is this even a good idea?

Update distance function

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.

Regarding the ABC PMC Tool Box

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.