def __init__(self,dim = 1, dist_type = None, var = None, order = None): self.dim = dim self.order = order self.nbpoly = order + 1 self.var = var self.dist_type = dist_type #self.coef = np.zeros(self.nbpoly, self.order + 1) if dist_type =='norm': self.funcs = np.array([sp.hermitenorm(i)for i in range (0, self.order+1)]) for i in range(0, self.order+1): normalized_const = np.sqrt(sp.factorial(i)) self.funcs[i] = poly1d(self.funcs[i].c/normalized_const) if dist_type =='uniform': #The polynomials are orthogonal over [0,1] with weight function 1. self.funcs = np.array([sp.sh_legendre(i)for i in range (0, self.order+1)]) for i in range(0, self.order+1): normalized_const = np.sqrt(1./(2.*i+1.)) self.funcs[i] = poly1d(self.funcs[i].c/normalized_const) self.modelcoef = np.zeros((self.nbpoly,))
def _lmomg(self, m, *args): "Compute the mth L-moment with a Legendre polynomial." P_r = special.sh_legendre(m - 1) func = lambda x: self._ppf(x, *args) * P_r(x) return integrate.quad(func, 0, 1)[0]
def _lmomg(self, m, *args): "Compute the mth L-moment with a Legendre polynomial." P_r = special.sh_legendre(m-1) func = lambda x : self._ppf(x, *args) * P_r(x) return integrate.quad(func, 0, 1)[0]
from scipy.special import sh_legendre, sph_harm P_6 = sh_legendre(6)