bcdaniels / coniii

Convenient Interface to Inverse Ising
MIT License
4 stars 1 forks source link

MCMC sampling speedup #15

Open eltrompetero opened 6 years ago

eltrompetero commented 6 years ago

Sampling is pretty slow right now. Can we speed this up?

eltrompetero commented 6 years ago

The default Metropolis sampling routine is not optimized for the Ising model and can handle general maxent problems. There is a FastMCIsing class that is faster with sampling from the Ising model, but it isn't integrated into the Solver class. I don't remember how much faster it was, but it should be significant.

ekvall93 commented 6 years ago

ohh, cool. I will check it out

ekvall93 commented 6 years ago

Indeed, FastMCIsing is quite a lot faster, but worse accuracy.

FastMCIsing: It has taken 88.0072619915 seconds to run CONIII ('neuons', 10) ('sample_size', 4000) ('KL Divergence', 0.4785795436062612) ('Error on correlations', 1.2537709500058687)

Metropolis: It has taken 137.988027096 seconds to run CONIII ('neuons', 10) ('sample_size', 4000) ('KL Divergence', 0.15355191649446209) ('Error on correlations', 0.10716371325930923)

Ps. By setting the h = np.mean(sample,axis=0), J = np.zeros(shape=n*(n-1)//2) as initial guess seems to speed it up a lot.

ekvall93 commented 6 years ago

I tried SWIsing and it did not speed it up either.

eltrompetero commented 6 years ago

I wouldn't play with SWIsing at the moment. Last I remember, it had some bugs, so I can't attest to its accuracy.

The time that MCH takes to converge will not only depend on the sampling method but random variations in the samples generated from MCMC. If MCH hasn't converged closely to the answer, you should keep running it til it close from what is expected from random fluctuations from sampling.

ekvall93 commented 6 years ago

Hi, Why aren't the solver in mc_hist.py used?

ekvall93 commented 6 years ago

Do you know If the algorithm will speed up If the values ins (1,0) rather than (-1,1)?

eltrompetero commented 5 years ago

Oops! Sorry I didn't realize I had dropped this thread...many months ago...

We are actually updating the software and porting to Python3. Some of your (helpfully pointed out) concerns will be addressed. I will have to get back to you about your comments.

Did you end up using our software?