Esempio n. 1
0
    def test_lnprior(self):
        t = np.arange(0, 1, 0.01)
        theta = self.random_theta(3, 2)
        kursl = KurSL(theta)
        model = ModelWrapper(kursl)
        lnprob = KurslMCMC.lnprior(theta, model)

        # Given default uniform probablities it's either 0 or -np.inf
        self.assertEqual(np.round(lnprob, 10), 0,
                         "Theta within max ranges results in 0")
Esempio n. 2
0
    def test_lnprior_theta_outside_ranges(self):
        t = np.arange(0, 1, 0.01)
        S = np.random.random(t.size)
        theta = self.random_theta(3, 2)
        kursl = KurSL(theta)
        model = ModelWrapper(kursl)

        new_theta = theta.copy()
        new_theta[0, 2] = model.MIN_R - 1
        self.assertEqual(KurslMCMC.lnprior(new_theta, model), -np.inf)
        new_theta[0, 2] = model.MAX_R + 1
        self.assertEqual(KurslMCMC.lnprior(new_theta, model), -np.inf)

        new_theta = theta.copy()
        new_theta[1, 0] = model.MIN_W - 1
        self.assertEqual(KurslMCMC.lnprior(new_theta, model), -np.inf)
        new_theta[1, 0] = model.MAX_W + 1
        self.assertEqual(KurslMCMC.lnprior(new_theta, model), -np.inf)

        # Check for W_i < sum_j (|k_ij|)
        new_theta = theta.copy()
        new_theta[2, 0] = np.sum(new_theta[2, 3:]) * 0.6
        self.assertEqual(KurslMCMC.lnprior(new_theta, model), -np.inf)