def _convolution_in_point(t_val, f, g, n_integral=100, inverse_time=None, return_log=False): ''' evaluates int_tau f(t+tau)g(tau) or int_tau f(t-tau)g(tau) if inverse time is TRUE ''' if inverse_time is None: raise Exception("Inverse time argument must be set!") # determine integration boundaries: if inverse_time: ## tau>g.xmin and t-tau<f.xmax tau_min = max(t_val - f.xmax, g.xmin) ## tau<g.xmax and t-tau>f.xmin tau_max = min(t_val - f.xmin, g.xmax) else: ## tau>g.xmin and t+tau>f.xmin tau_min = max(f.xmin - t_val, g.xmin) ## tau<g.xmax and t+tau<f.xmax tau_max = min(f.xmax - t_val, g.xmax) #print(tau_min, tau_max) if tau_max <= tau_min + ttconf.TINY_NUMBER: if return_log: return ttconf.BIG_NUMBER else: return 0.0 # functions do not overlap else: # create the tau-grid for the interpolation object in the overlap region if inverse_time: tau = np.unique( np.concatenate((g.x, t_val - f.x, [tau_min, tau_max]))) else: tau = np.unique( np.concatenate((g.x, f.x - t_val, [tau_min, tau_max]))) tau = tau[(tau > tau_min - ttconf.TINY_NUMBER) & (tau < tau_max + ttconf.TINY_NUMBER)] if len(tau) < 10: tau = np.linspace(tau_min, tau_max, 10) if inverse_time: # add negative logarithms fg = f(t_val - tau) + g(tau) else: fg = f(t_val + tau) + g(tau) # create the interpolation object on this grid FG = Distribution(tau, fg, is_log=True, kind='linear') #integrate the interpolation object, return log, make neg_log #print('FG:',FG.xmin, FG.xmax, FG(FG.xmin), FG(FG.xmax)) res = -FG.integrate( a=FG.xmin, b=FG.xmax, n=n_integral, return_log=True) if return_log: return res else: return np.exp(-res)