There appears to a off by one error in negbin update function.
Adding a -1 to the index seems to resolve the issue.
self.acceptances[self.sample_iter-1] = True
Traceback (most recent call last)
Cell In[48], line 1
----> 1 mcmc_negbin = md2.negbin.run_graph(
2 mcmc_negbin,
3 crash_if_error=True
4 )
File ~/miniforge3/envs/mdsine2/lib/python3.11/site-packages/mdsine2/negbin.py:1053, in run_graph(mcmc, crash_if_error, log_every)
1038 '''Run the MCMC chain mcmc. Initialize the MCMC chain with build_graph
1039
1040 Parameters
(...)
1050 mdsine2.BaseMCMC
1051 '''
1052 try:
-> 1053 mcmc.run(log_every=log_every)
1054 except Exception as e:
1055 logger.critical('CHAIN {} CRASHED'.format(mcmc.graph.name))
File ~/miniforge3/envs/mdsine2/lib/python3.11/site-packages/mdsine2/pylab/inference.py:524, in BaseMCMC.run(self, log_every, benchmarking)
522 try:
523 with time_counter() as t:
--> 524 node.update()
525 node.add_trace()
527 if benchmarking:
File ~/miniforge3/envs/mdsine2/lib/python3.11/site-packages/mdsine2/negbin.py:311, in NegBinDispersionParam.update(self)
309 u = np.log(pl.random.misc.fast_sample_standard_uniform())
310 if r > u:
--> 311 self.acceptances[self.sample_iter] = True
312 self.temp_acceptances += 1
313 else:
IndexError: index 2000 is out of bounds for axis 0 with size 2000
There appears to a off by one error in negbin update function.
Adding a -1 to the index seems to resolve the issue.
self.acceptances[self.sample_iter-1] = True
Traceback (most recent call last)
Cell In[48], line 1
----> 1 mcmc_negbin = md2.negbin.run_graph(
2 mcmc_negbin,
3 crash_if_error=True
4 )
File ~/miniforge3/envs/mdsine2/lib/python3.11/site-packages/mdsine2/negbin.py:1053, in run_graph(mcmc, crash_if_error, log_every)
1038 '''Run the MCMC chain
mcmc. Initialize the MCMC chain withbuild_graph1039
1040 Parameters
(...)
1050 mdsine2.BaseMCMC
1051 '''
1052 try:
-> 1053 mcmc.run(log_every=log_every)
1054 except Exception as e:
1055 logger.critical('CHAIN
{}CRASHED'.format(mcmc.graph.name))File ~/miniforge3/envs/mdsine2/lib/python3.11/site-packages/mdsine2/pylab/inference.py:524, in BaseMCMC.run(self, log_every, benchmarking)
522 try:
523 with time_counter() as t:
--> 524 node.update()
525 node.add_trace()
527 if benchmarking:
File ~/miniforge3/envs/mdsine2/lib/python3.11/site-packages/mdsine2/negbin.py:311, in NegBinDispersionParam.update(self)
309 u = np.log(pl.random.misc.fast_sample_standard_uniform())
310 if r > u:
--> 311 self.acceptances[self.sample_iter] = True
312 self.temp_acceptances += 1
313 else:
IndexError: index 2000 is out of bounds for axis 0 with size 2000