Met4FoF / npl-jitter-noise-removal-mcmc

NPL Jitter Noise Removal MCMC
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Error with positive-definite matrix #3

Open bangxiangyong opened 3 years ago

bangxiangyong commented 3 years ago

Upon running the code , i found the following error occassionally at random times :

Exception in thread Thread-125:
Traceback (most recent call last):
  File "C:\Users\bxy20\Miniconda3\envs\NPL-Jitter\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\bxy20\Miniconda3\envs\NPL-Jitter\lib\threading.py", line 1254, in run
    self.function(*self.args, **self.kwargs)
  File "C:\Users\bxy20\Miniconda3\envs\NPL-Jitter\lib\site-packages\agentMET4FOF\agents.py", line 923, in handle_function
    self.repeat_function()
  File "C:\Users\bxy20\Miniconda3\envs\NPL-Jitter\lib\site-packages\agentMET4FOF\agents.py", line 1104, in step
    self.schedule.step()
  File "C:\Users\bxy20\Miniconda3\envs\NPL-Jitter\lib\site-packages\mesa\time.py", line 84, in step
    agent.step()
  File "C:\Users\bxy20\Miniconda3\envs\NPL-Jitter\lib\site-packages\agentMET4FOF\agents.py", line 69, in step
    self.handle_process_data(self.mesa_message_queue.popleft())
  File "C:\Users\bxy20\Miniconda3\envs\NPL-Jitter\lib\site-packages\agentMET4FOF\agents.py", line 449, in handle_process_data
    self.on_received_message(message)
  File "F:/NPL-Jitter/NJ_with_MCMC_agent.py", line 36, in on_received_message
    t = njr(self.fs, self.ydata, self.N, self.niter, self.tol, self.m0w, self.s0w, self.m0t, self.s0t, self.Mc, self.M0,self.Nc, self.Q)
  File "F:/NPL-Jitter/NJ_with_MCMC_agent.py", line 10, in njr
    yhat1= analyse_fun.AnalyseSignalN()
  File "F:\NPL-Jitter\NJRemove\NJRemoval_class_withmcmc.py", line 111, in AnalyseSignalN
    outs = MCMCMH.mcmcm_decayexp.main(self.ydata, datax, self.m0w, self.s0w, self.m0t, self.s0t, self.Mc, self.M0, self.Nc, self.Q)
  File "F:\NPL-Jitter\MCMCMH\mcmcm_decayexp.py", line 451, in main
    L = np.linalg.cholesky(V)
  File "<__array_function__ internals>", line 5, in cholesky
  File "C:\Users\bxy20\Miniconda3\envs\NPL-Jitter\lib\site-packages\numpy\linalg\linalg.py", line 763, in cholesky
    r = gufunc(a, signature=signature, extobj=extobj)
  File "C:\Users\bxy20\Miniconda3\envs\NPL-Jitter\lib\site-packages\numpy\linalg\linalg.py", line 91, in _raise_linalgerror_nonposdef
    raise LinAlgError("Matrix is not positive definite")
numpy.linalg.LinAlgError: Matrix is not positive definite
BjoernLudwigPTB commented 3 years ago

We nailed it down to finding the cholesky factorization of the optimzation in line 448 in mcmcm_decayexp.main. We could try to find a way to allow for a proper minimization in case of an error at first. @anupam-prasad 's idea was to maybe wiggle at at0 and repeat the minimization attempts until they succeed. @mgrub suggested to then find abortion createria to avoid getting stuck in the loop. For now we should try to live with the error to save time in the inclusion of the methods into agentMET4FOF.