def error(self, start, end) -> float:
        """Return the approximation cost on the segment [start:end].

        Args:
            start (int): start of the segment
            end (int): end of the segment

        Returns:
            segment cost (float)

        Raises:
            NotEnoughPoints: when the segment is too short (less than `min_size`
                samples).
        """
        if end - start < self.min_size:
            raise NotEnoughPoints

        if start == 0:
            start = 1

        sub = self.signal[start:end]
        slope = (self.signal[end - 1] - self.signal[start - 1]) / (end - start)
        intercept = self.signal[start - 1]
        approx = slope.reshape(-1, 1) * np.arange(
            1, end - start + 1
        ) + intercept.reshape(-1, 1)
        return np.sum((sub - approx.transpose()) ** 2)
Return the approximation cost on the segment [start:end].

        Args:
            start (int): start of the segment
            end (int): end of the segment

        Returns:
            segment cost (float)

        Raises:
            NotEnoughPoints: when the segment is too short (less than `min_size`
                samples).
        
src/ruptures/costs/costclinear.py