projects/nnum/interpolation/lagrangian.py
def predict(self, t):
        """Interpolate the function f described by the data X to predict f(t).

        :param t:
            The point of interest, where f(t) should be predicted.

        :return:
            :float: the interpolated value for f(t).
        """
        if self.fitting_profile == 'local':
            # Select the "degree+1" closest points to t.
            indices = np.argsort(np.abs(self.X - t), axis=0)[:self.degree + 1]

        else:
            # Select the "degree + 1" most sparse points.
            indices = [i * self.X.shape[0] // self.degree + self.X.shape[0]
                       // (2 * self.degree) for i in range(self.degree)]

            # Shift points so the extremes of the interval are included.
            indices = [v - self.X.shape[0] // (2 * self.degree) for i, v in
                       enumerate(indices[:len(indices) // 2 + 1])] \
                      + [v + (self.X.shape[0] - 1) // (2 * self.degree) for i, v in
                         enumerate(indices[len(indices) // 2:])]

        # The points found are ordered by distance to :t (e.g., 5, 1, 0, 3).
        # Reorder them by their indices (e.g.: 0, 1, 3, 5).
        indices = np.sort(indices).flatten()
        return sum((self.y[i] * self.l(i, t, indices) for i in indices))
Interpolate the function f described by the data X to predict f(t).

        :param t:
            The point of interest, where f(t) should be predicted.

        :return:
            :float: the interpolated value for f(t).
        
Interpolate the function f described by the data X to predict f(t).
Interpolate the function f described by the data X to predict f ( t ) .
def predict(self, t):
        if self.fitting_profile == 'local':
            indices = np.argsort(np.abs(self.X - t), axis=0)[:self.degree + 1]
        else:
            indices = [i * self.X.shape[0] // self.degree + self.X.shape[0]
                       // (2 * self.degree) for i in range(self.degree)]
            indices = [v - self.X.shape[0] // (2 * self.degree) for i, v in
                       enumerate(indices[:len(indices) // 2 + 1])] \
                      + [v + (self.X.shape[0] - 1) // (2 * self.degree) for i, v in
                         enumerate(indices[len(indices) // 2:])]
        indices = np.sort(indices).flatten()
        return sum((self.y[i] * self.l(i, t, indices) for i in indices))
def predict ( self , t ) : if self . fitting_profile == 'local' : indices = np . argsort ( np . abs ( self . X - t ) , axis = 0 ) [ : self . degree + 1 ] else : indices = [ i * self . X . shape [ 0 ] // self . degree + self . X . shape [ 0 ] // ( 2 * self . degree ) for i in range ( self . degree ) ] indices = [ v - self . X . shape [ 0 ] // ( 2 * self . degree ) for i , v in enumerate ( indices [ : len ( indices ) // 2 + 1 ] ) ] + [ v + ( self . X . shape [ 0 ] - 1 ) // ( 2 * self . degree ) for i , v in enumerate ( indices [ len ( indices ) // 2 : ] ) ] indices = np . sort ( indices ) . flatten ( ) return sum ( ( self . y [ i ] * self . l ( i , t , indices ) for i in indices ) )
Interpolate the function f described by the data X to predict f(t).
Interpolate the function f described by the data X to predict f ( t ) .
"""Interpolate the function f described by the data X to predict f(t).

        :param t:
            The point of interest, where f(t) should be predicted.

        :return:
            :float: the interpolated value for f(t).
        """ # Select the "degree+1" closest points to t. # Select the "degree + 1" most sparse points. # Shift points so the extremes of the interval are included. # The points found are ordered by distance to :t (e.g., 5, 1, 0, 3). # Reorder them by their indices (e.g.: 0, 1, 3, 5).
:float: the interpolated value for f(t).
: float : the interpolated value for f ( t ) .
self
t
The point of interest, where f(t) should be predicted.
The point of interest where f ( t ) should be predicted .