def time_opt(self): p, x = [], [] for col in range(1, self.num_points): p.extend(self.upper_tri_col(col)) x.extend(self.diff_col_times(col)) ker = self.time_kernel_provider(x, p) return kernels.Reflect1D(ker)
def func_opt(self): times, probs = self._times_probs_for_func_opt() ker = kernels.GaussianBase(times) ker.covariance_matrix = 1 ker.bandwidth = self._h ker.weights = probs return kernels.Reflect1D(ker)
def test_Reflect1D(): def kernel(pts): return np.exp(-pts*pts) k = testmod.Reflect1D(kernel) assert k.kernel is kernel assert k(5) == pytest.approx(2*np.exp(-25)) np.testing.assert_allclose(k([5,7]), 2*np.exp([-25, -49]))
def compute_t_marginal(ker): """Return the kernel resulting from integrating out all but the first coordinate. Handles the case when a cutoff is applied, but does not apply the cutoff in the calculation! :param ker: Any of the kernels returned by the providers in this module. """ if isinstance(ker, kernels.Reflect1D): return ValueError("Already a one dimensional kernel!") already_reflected_axis = None if isinstance(ker, kernels.ReflectedKernel): already_reflected_axis = ker.reflected_axis ker = ker.delegate if isinstance(ker, _WrapWithCutoff): ker = ker._ker k = kernels.marginalise_gaussian_kernel(ker, 2) k = kernels.marginalise_gaussian_kernel(k, 1) if already_reflected_axis == 0: return kernels.Reflect1D(k) return k
def trigger_time_opt(self): _, trigs = self._sample_points() ker = self.trigger_time_provider(trigs[0], None) return kernels.Reflect1D(ker)
def trigger_time_opt(self): pts, w = self._cached_trigger_data() kt = self.trigger_time_provider(pts[0], w) return kernels.Reflect1D(kt)
def func_opt(self): times, probs = self._times_probs_for_func_opt() ker = kernels.GaussianNearestNeighbour(times, self._knn) ker.weights = probs return kernels.Reflect1D(ker)
def time_opt(self): times = self._sample_triggers()[0] ker = self.time_kernel_provider(times, None) return kernels.Reflect1D(ker)