(X, tol, g, gprime, fun_args, maxit, w_init)
return W
Deflationary FastICA using fun approx to neg-entropy function

    Used internally by FastICA.
Deflationary FastICA using fun approx to neg-entropy function
Deflationary FastICA using fun approx to neg - entropy function
def _ica_def(X, tol, g, gprime, fun_args, maxit, w_init):
    """Deflationary FastICA using fun approx to neg-entropy function

    Used internally by FastICA.
    """

    n_comp = w_init.shape[0]
    W = np.zeros((n_comp, n_comp), dtype=float)

    # j is the index of the extracted component
    for j in range(n_comp):
        w = w_init[j, :].copy()
        w /= np.sqrt((w**2).sum())

        n_iterations = 0
        # we set lim to tol+1 to be sure to enter at least once in next while
        lim = tol + 1 
        while ((lim > tol) & (n_iterations < (maxit-1))):
            wtx = np.dot(w.T, X)
            gwtx = g(wtx, fun_args)
            g_wtx = gprime(wtx, fun_args)
            w1 = (X * gwtx).mean(axis=1) - g_wtx.mean() * w
            
            _gs_decorrelation(w1, W, j)
            
            w1 /= np.sqrt((w1**2).sum())

            lim = np.abs(np.abs((w1 * w).sum()) - 1)
            w = w1
            n_iterations = n_iterations + 1
            
        W[j, :] = w

    return W
def _ica_def ( X , tol , g , gprime , fun_args , maxit , w_init ) : n_comp = w_init . shape [ 0 ] W = np . zeros ( ( n_comp , n_comp ) , dtype = float ) # j is the index of the extracted component for j in range ( n_comp ) : w = w_init [ j , : ] . copy ( ) w /= np . sqrt ( ( w ** 2 ) . sum ( ) ) n_iterations = 0 # we set lim to tol+1 to be sure to enter at least once in next while lim = tol + 1 while ( ( lim > tol ) & ( n_iterations < ( maxit - 1 ) ) ) : wtx = np . dot ( w . T , X ) gwtx = g ( wtx , fun_args ) g_wtx = gprime ( wtx , fun_args ) w1 = ( X * gwtx ) . mean ( axis = 1 ) - g_wtx . mean ( ) * w _gs_decorrelation ( w1 , W , j ) w1 /= np . sqrt ( ( w1 ** 2 ) . sum ( ) ) lim = np . abs ( np . abs ( ( w1 * w ) . sum ( ) ) - 1 ) w = w1 n_iterations = n_iterations + 1 W [ j , : ] = w return W