def cramerVonMises(x, y): try: x = sorted(x); y = sorted(y); pool = x + y; ps, pr = _sortRank(pool) rx = array ( [ pr[ind] for ind in [ ps.index(element) for element in x ] ] ) ry = array ( [ pr[ind] for ind in [ ps.index(element) for element in y ] ] ) n = len(x) m = len(y) i = array(range(1, n+1)) j = array(range(1, m+1)) u = n * sum ( power( (rx - i), 2 ) ) + m * sum ( power((ry - j), 2) ) t = u / (n*m*(n+m)) - (4*n*m-1) / (6 * (n+m)) Tmu = 1/6 + 1 / (6*(n+m)) Tvar = 1/45 * ( (m+n+1) / power((m+n),2) ) * (4*m*n*(m+n) - 3*(power(m,2) + power(n,2)) - 2*m*n) / (4*m*n) t = (t - Tmu) / power(45*Tvar, 0.5) + 1/6 if t < 0: return -1 elif t <= 12: a = 1-mp.nsum(lambda x : ( mp.gamma(x+0.5) / ( mp.gamma(0.5) * mp.fac(x) ) ) * mp.power( 4*x + 1, 0.5 ) * mp.exp ( - mp.power(4*x + 1, 2) / (16*t) ) * mp.besselk(0.25 , mp.power(4*x + 1, 2) / (16*t) ), [0,100] ) / (mp.pi*mp.sqrt(t)) return float(mp.nstr(a,3)) else: return 0 except Exception as e: print e return -1
def _f(x): return mp.gamma(g+1)* \ np.power(x/mpf(2), -g) * \ mp.exp(1j*x) * mp.besselj(g, x)
def asym_arg(eta, x, l_f): sigma_l = cmath.phase(complex(symmath.gamma(l_f + 1 + 1.0j*eta))) return x - eta * np.log(2.0*x) -0.5*l_f*np.pi + sigma_l
def asym_arg(eta, x, l_f): sigma_l = cmath.phase(complex(symmath.gamma(l_f + 1 + 1.0j * eta))) return x - eta * np.log(2.0 * x) - 0.5 * l_f * np.pi + sigma_l