function g = nllicaGrad(w, X, beta); % % gradient of the negative log likelihood of ICA model % using a Generalized Gaussian distribution with parameter beta in 2-d. % input % w: vectorized form of unmixing matrix W % X: data matrix % beta: parameter of Generalized Gaussian distribution % output % g: gradient vector W = reshape(w,2,2); N = size(X,2); WI = 1/(W(1,1)*W(2,2) - W(1,2)*W(2,1))*[ W(2,2) -W(1,2); -W(2,1) ... W(1,1) ]; if beta == 1 g = N*WI' - sign(W*X)*X'; else g = N*WI' - (beta*sign(W*X).*abs(W*X).^(beta-1))*X'; end g = -g(:)';