Hi Anderson, I've noticed palm_gtoz function may produce Inf or -Inf values on Z and it causes NaN related errors afterwards. This happens when input of erfcinv is close to 0 or 2 within matlab's numerical precision. So, I would alternate Inf or -Inf values on Z as maximum or minimum values of Z to prevent this problem, by putting following codes in the end of palm_gtoz.m: z_max = max(Z(Z ~= Inf)); z_min = min(Z(Z ~= -Inf)); Z(Z == Inf) = z_max; Z(Z == -Inf) = z_min; Does this make sense? Thanks, Dongjin