def get_mean_stdev_r_squared(self, x, y):
        # remove all x,y's if y is less than or equal to 0
        yy, xx = ExponentialDistributionFunction._remove_non_positive_values(y, x)

        x_, y_mean, y_std = ExponentialDistributionFunction._get_means_stdevs(x, [y_i for y_i in yy])
        # these have to be of the form y = c x + d, therefore we use ln(y) = b x + ln(a)
        # which (in theory) is equivalent to y = a e^(bx)
        mu = get_r_squared(x_, y_mean, self.mean_b, ln(self.mean_a))
        sigma = get_r_squared(x_, y_std, self.stdev_b, ln(self.stdev_a))
        return mu, sigma
Exemple #2
0
 def test_bad_fit(self):
     self.a = 4
     self.b = 2
     r_s = get_r_squared(self.x, self.y, self.a, self.b)
     self.assertAlmostEqual(r_s, -7.2)
Exemple #3
0
 def test_simple_case(self):
     r_s = get_r_squared(self.x, self.y, self.a, self.b)
     self.assertEqual(r_s, 1)
 def get_mean_stdev_r_squared(self, x, y):
     x_, y_mean, y_std = LinearDistributionFunction._get_means_stdevs(x, y)
     mu = get_r_squared(x_, y_mean, self.mean_a, self.mean_b)
     sigma = get_r_squared(x_, y_std, self.stdev_a, self.stdev_b)
     return mu, sigma