LSSTDESC / CLMM

A Python library for performing galaxy cluster mass reconstruction from weak lensing observables
BSD 3-Clause "New" or "Revised" License
24 stars 20 forks source link

Update NumCosmo walkers #436

Closed combet closed 8 months ago

combet commented 3 years ago

From @vitenti - API has slightly changed with the latest conda released of NC (v0.15.4). In NumCosmo examples, e.g. example2...:

Ncm.FitESMCMCWalkerAPS.new (nwalkers, mset3.fparams_len ()) should be replaced by Ncm.FitESMCMCWalkerAPES.new (nwalkers, mset3.fparams_len ())

Also, with this new version of the sampler, the number of walkers needs to be increase nwalkers = 100 --> nwalkers=800

hsinfan1996 commented 3 years ago

The version number of NC seems to be 1 after NC gets imported. Not sure if it is possible to distinguish between different versions of NC. Cell 22:

try:
    nwalkers = 100 # Number of walkers
    walker = Ncm.FitESMCMCWalkerAPS.new (nwalkers, mset3.fparams_len ())
except AttributeError:
    nwalkers=800
    walker = Ncm.FitESMCMCWalkerAPES.new (nwalkers, mset3.fparams_len ())

Cell 26:

try:
    nwalkers = 100
    stretch = Ncm.FitESMCMCWalkerAPS.new (nwalkers, mset3.fparams_len ())
except AttributeError:
    nwalkers=800
    stretch = Ncm.FitESMCMCWalkerAPES.new (nwalkers, mset3.fparams_len ())
hsinfan1996 commented 3 years ago

@vitenti In Example2, I tested cell 26 with different versions of NC and the results are: v0.15.3: 100 walkers, ~23 min (10000 steps) v0.15.4: 800 walkers, ~37 min (16000 steps)

vitenti commented 3 years ago

@hsinfan1996 In the lastest version (on github) you can try the old behavior of APES using:

Ncm.FitESMCMCWalkerAPES.new_full (nwalkers, mset.fparams_len (), Ncm.FitESMCMCWalkerAPESMethod.KDE, Ncm.FitESMCMCWalkerAPESKType.CAUCHY, 1.0, True)

I'll be releasing a new version of NumCosmo that includes this possibility in the next days. If you like, you could test using this constructor and 100 walkers to see if the previous results is recovered.

The default method used by apes now is Ncm.FitESMCMCWalkerAPESMethod.VKDE which is more costly but much more powerful to probe complicated posteriors.

hsinfan1996 commented 3 years ago

@hsinfan1996 In the lastest version (on github) you can try the old behavior of APES using:

Ncm.FitESMCMCWalkerAPES.new_full (nwalkers, mset.fparams_len (), Ncm.FitESMCMCWalkerAPESMethod.KDE, Ncm.FitESMCMCWalkerAPESKType.CAUCHY, 1.0, True)

I'll be releasing a new version of NumCosmo that includes this possibility in the next days. If you like, you could test using this constructor and 100 walkers to see if the previous results is recovered.

The default method used by apes now is Ncm.FitESMCMCWalkerAPESMethod.VKDE which is more costly but much more powerful to probe complicated posteriors.

Thanks. It is good that I do not have to switch between different versions now. I am able to install NC from github, and I will get back to you once I finish the tests.

hsinfan1996 commented 3 years ago

@vitenti @combet NC 0.15.4 old method: ~33 min, 14000 moves new method: same as previous I am not sure how should I proceed given what I have right now, because I don't know how NC determines how many steps are needed for each MCMC run. It looks like time per step is the same regardless of the algorithms, so the total number of steps is more important.