def betaDeriva(self, X, Y, beta, xi): v = X.dot(beta).reshape(-1, 1) y = Y.reshape(-1, 1) GEVFunc.clip(xi, v) gev = GEVFunc.GEV(xi, v) loggev = GEVFunc.logGEV(xi, v) res = - np.sum(X * (loggev * (y - gev) / ((1 - gev) * (1 + xi*v))), axis=0) - beta return res
def xiDeriva(self, X, Y, beta, xi): v = X.dot(beta).reshape(-1, 1) y = Y.reshape(-1, 1) GEVFunc.clip(xi, v) gev = GEVFunc.GEV(xi, v) loggev = GEVFunc.logGEV(xi, v) res = np.sum((np.log(1 + xi*v) / xi**2 - v / xi / (1 + xi*v)) * loggev * (y - gev) / (1 - gev)) - xi return res
def xiSecDeriva(self, X, Y, beta, xi): v = X.dot(beta).reshape(-1, 1) GEVFunc.clip(xi, v) y = Y.reshape(-1, 1) a = 1 + xi*v gev = GEVFunc.GEV(xi, v) loggev = GEVFunc.logGEV(xi, v) y_gev = y - gev one_gev = 1 - gev y_gev_1_gev = y_gev/one_gev xia = xi * a xiv = xi * v lna = np.log(a) comp1 = (xiv * (3*a-1) - 2*lna*(a**2)) / (xi * xia**2) * y_gev_1_gev * loggev comp2 = (1/xi**2 * lna - v/xia) * ((y-1)*loggev*gev/one_gev**2 + y_gev_1_gev) * (v/xia-lna/xi**2)/np.power(a, 1./xi) return np.sum(comp1 + comp2) - 1