def choose_efold(self, y, verbose=False):
        ngrid = 20
        efold_grid = np.logspace(-1.0, np.log10(self.lookback * 2.0), ngrid)
        gcv_grid = np.zeros(efold_grid.size)
        for i in xrange(efold_grid.size):
            smoothed_y, peffective = self._smooth(efold_grid[i], y)
            gcv_grid[i] = gcv_error(y, smoothed_y, peffective)

        # choose e-folding length of smoother to minimize the generalized cross-validation error
        self.efold = efold_grid[gcv_grid.argmin()]
        if verbose:
            print 'E-folding length chosen to be', self.efold

        # save the grids
        self.efold_grid = efold_grid
        self.gcv_grid = gcv_grid
Choose the optimal e-folding length of the exponential smoothing kernel using generalized cross-validation.
dataset/ETHPy150Open brandonckelly/bck_stats/bck_stats/gcv_smoother.py/GcvExpSmoother.choose_efold