Exemple #1
0
    def test_bilinear_residuals_stepp(self):
        # Calculates residual sum of squares (RSS) for two test cases
        # i) RSS > 0 (alternating +/- residuals)
        # ii) RSS = 0
        # Offset = +/- 0.1
        offset1 = np.array(
            [0.1, -0.1, 0.1, -0.1, 0.1, -0.1, 0.1, -0.1, 0.1, -0.1, 0.1])
        y_offset1 = self.ydata + offset1
        self.assertAlmostEqual(
            np.sum(offset1**2.),
            get_bilinear_residuals_stepp(self.params[1:], self.xdata,
                                         y_offset1, self.params[0]))

        # Zero offset
        y_offset0 = self.ydata + np.zeros(11, dtype=float)
        self.assertAlmostEqual(
            0.0,
            get_bilinear_residuals_stepp(self.params[1:], self.xdata,
                                         y_offset0, self.params[0]))
    def test_bilinear_residuals_stepp(self):
        # Calculates residual sum of squares (RSS) for two test cases
        # i) RSS > 0 (alternating +/- residuals)
        # ii) RSS = 0
        # Offset = +/- 0.1
        offset1 = np.array([0.1, -0.1, 0.1, -0.1, 0.1, -0.1, 0.1, -0.1, 0.1,
                            -0.1, 0.1])
        y_offset1 = self.ydata + offset1
        self.assertAlmostEqual(
            np.sum(offset1 ** 2.),
            get_bilinear_residuals_stepp(self.params[1:], self.xdata,
                                         y_offset1, self.params[0]))

        # Zero offset
        y_offset0 = self.ydata + np.zeros(11, dtype=float)
        self.assertAlmostEqual(0.0, get_bilinear_residuals_stepp(
            self.params[1:],
            self.xdata,
            y_offset0,
            self.params[0]))