def get_solid_harmonics(l, r, x, y, z): def get_pi(l, m): terms = [] for k in xrange((l - m) / 2 + 1): factor = (-1)**k * int( binomial(l, k) * binomial(2 * l - 2 * k, l) * fac(l - 2 * k)) / S(2**l * int(fac(l - 2 * k - m))) terms.append(factor * r**(2 * k) * z**(l - 2 * k - m)) return Add(*terms) def get_a(m): terms = [] for p in xrange(m + 1): factor = int(binomial(m, p)) * cos((m - p) * pi / S(2)) terms.append(factor * x**p * y**(m - p)) return Add(*terms) def get_b(m): terms = [] for p in xrange(m + 1): factor = int(binomial(m, p)) * sin((m - p) * pi / S(2)) terms.append(factor * x**p * y**(m - p)) return Add(*terms) result = [] for m in xrange(l + 1): if m == 0: result.append(get_pi(l, m) * get_a(m)) else: factor = sqrt(2 * int(fac(l - m)) / S(int(fac(l + m)))) result.append(factor * get_pi(l, m) * get_a(m)) result.append(factor * get_pi(l, m) * get_b(m)) return result
def get_solid_harmonics(l, r, x, y, z): def get_pi(l, m): terms = [] for k in xrange((l-m)/2+1): factor = (-1)**k*int(binomial(l,k)*binomial(2*l-2*k,l)*fac(l-2*k))/S(2**l*int(fac(l-2*k-m))) terms.append(factor*r**(2*k)*z**(l-2*k-m)) return Add(*terms) def get_a(m): terms = [] for p in xrange(m+1): factor = int(binomial(m, p))*cos((m-p)*pi/S(2)) terms.append(factor*x**p*y**(m-p)) return Add(*terms) def get_b(m): terms = [] for p in xrange(m+1): factor = int(binomial(m, p))*sin((m-p)*pi/S(2)) terms.append(factor*x**p*y**(m-p)) return Add(*terms) result = [] for m in xrange(l+1): if m == 0: result.append(get_pi(l, m)*get_a(m)) else: factor = sqrt(2*int(fac(l-m))/S(int(fac(l+m)))) result.append(factor*get_pi(l, m)*get_a(m)) result.append(factor*get_pi(l, m)*get_b(m)) return result
def get_pi(l, m): terms = [] for k in xrange((l - m) / 2 + 1): factor = (-1)**k * int( binomial(l, k) * binomial(2 * l - 2 * k, l) * fac(l - 2 * k)) / S(2**l * int(fac(l - 2 * k - m))) terms.append(factor * r**(2 * k) * z**(l - 2 * k - m)) return Add(*terms)
def group_order(self): """ This method returns the order of the Weyl group. For types A, B, C, D, and E the order depends on the rank of the Lie algebra. For types F and G, the order is fixed. Example ======= >>> from sympy.liealgebras.weyl_group import WeylGroup >>> c = WeylGroup("D4") >>> c.group_order() 192.0 """ n = self.cartan_type.rank() if self.cartan_type.series == "A": return fac(n + 1) if self.cartan_type.series == "B" or self.cartan_type.series == "C": return fac(n) * (2**n) if self.cartan_type.series == "D": return fac(n) * (2**(n - 1)) if self.cartan_type.series == "E": if n == 6: return 51840 if n == 7: return 2903040 if n == 8: return 696729600 if self.cartan_type.series == "F": return 1152 if self.cartan_type.series == "G": return 12
def group_order(self): """ This method returns the order of the Weyl group. For types A, B, C, D, and E the order depends on the rank of the Lie algebra. For types F and G, the order is fixed. Example ======= >>> from sympy.liealgebras.weyl_group import WeylGroup >>> c = WeylGroup("D4") >>> c.group_order() 192.0 """ n = self.cartan_type.rank() if self.cartan_type.series == "A": return fac(n+1) if self.cartan_type.series == "B" or self.cartan_type.series == "C": return fac(n)*(2**n) if self.cartan_type.series == "D": return fac(n)*(2**(n-1)) if self.cartan_type.series == "E": if n == 6: return 51840 if n == 7: return 2903040 if n == 8: return 696729600 if self.cartan_type.series == "F": return 1152 if self.cartan_type.series == "G": return 12
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 get_pi(l, m): terms = [] for k in xrange((l-m)/2+1): factor = (-1)**k*int(binomial(l,k)*binomial(2*l-2*k,l)*fac(l-2*k))/S(2**l*int(fac(l-2*k-m))) terms.append(factor*r**(2*k)*z**(l-2*k-m)) return Add(*terms)
def combs(N, M): return fac(N) / fac(M) / fac(N - M)