def lognormal_minmax_log(kmin, kmax, mu, sigma): '''returns the sum( 1/k*exp(-0.5*((lnk - mu)/sigma)^2),{k,kmin,kmax} ) with kmax=None for infty ''' # print kmin,kmax,mu,sigma mpm.mp.dps = 15 if kmax == None: x = mpm.log( mpm.sumem( lambda k: 1.0 / (k - kmin + 1.0) * mpm.exp(-0.5 * (mpm.log( (k - kmin + 1.0)) - mu) * (mpm.log( (k - kmin + 1.0)) - mu) / sigma / sigma), [kmin, mpm.inf])) if mpm.im(x) != 0: logS = float(mpm.fabs(x)) else: logS = float(x) else: logS = (float( mpm.log( mpm.sumem( lambda k: 1.0 / (k - kmin + 1.0) * mpm.exp(-0.5 * (mpm.log( (k - kmin + 1.0)) - mu) * (mpm.log( (k - kmin + 1.0)) - mu) / sigma / sigma), [kmin, kmax])))) return logS
def weibull_minmax(kmin, kmax, gamma, b): '''returns the sum( k^(gamma-1)*exp(-b*(k)^gamma),{k,kmin,kmax} ) with kmax=None for infty ''' gamma = float(gamma) b = float(b) mpm.mp.dps = 15 if kmax == None: S = (float( mpm.sumem(lambda k: k**(gamma - 1.0) * mpm.exp(-b * k**gamma), [kmin, mpm.inf]))) else: S = (float( mpm.sumem(lambda k: k**(gamma - 1.0) * mpm.exp(-b * k**gamma), [kmin, kmax]))) return S
def zeta_minmax(gamma, kmin, kmax): '''kmax == None means kmax --> infty ''' # gamma = gamma[0] if gamma <= 1.0: if kmax == None: print('ERROR: Series does not converge!!!') C = 0 else: mpm.dps = 25 # print(gamma,kmin,kmax,'huhu') C = (float(mpm.sumem(lambda k: k**(-gamma), [kmin, kmax]))) else: # print(kmax) # print(type(kmax)) # print(kmax==None) # print('') if isinstance(kmax, (list, np.ndarray)): C = zeta(gamma, kmin) - zeta(gamma, kmax) elif kmax == None: C = zeta(gamma, kmin) else: C = zeta(gamma, kmin) - zeta(gamma, kmax) # print(C) return C
def lognormal_minmax(kmin, kmax, mu, sigma): '''returns the sum( 1/sqrt(2*pi*sigma^2)/k*exp(-0.5*((lnk - mu)/sigma)^2),{k,kmin,kmax} ) with kmax=None for infty ''' mpm.mp.dps = 15 if kmax == None: S = (float( mpm.sumem( lambda k: 1.0 / (k - kmin + 1.0) * mpm.exp(-0.5 * (mpm.log( (k - kmin + 1.0)) - mu) * (mpm.log( (k - kmin + 1.0)) - mu) / sigma / sigma), [kmin, mpm.inf]))) else: S = (float( mpm.sumem( lambda k: 1.0 / (k - kmin + 1.0) * mpm.exp(-0.5 * (mpm.log( (k - kmin + 1.0)) - mu) * (mpm.log( (k - kmin + 1.0)) - mu) / sigma / sigma), [kmin, kmax]))) return S
def weibull_minmax_log(kmin, kmax, gamma, b): '''returns the sum( k^(gamma-1)*exp(-b*(k)^gamma),{k,kmin,kmax} ) with kmax=None for infty ''' gamma = float(gamma) b = float(b) mpm.mp.dps = 15 if kmax == None: x = mpm.sumem(lambda k: k**(gamma - 1.0) * mpm.exp(-b * k**gamma), [kmin, mpm.inf]) if mpm.im(x) != 0: logS = float(mpm.fabs(x)) else: logS = float(x) else: logS = float( mpm.log( mpm.sumem(lambda k: k**(gamma - 1.0) * mpm.exp(-b * k**gamma), [kmin, kmax]))) return logS