def getRes(p, real, kind): unitmae = list() unitrmse = list() beta = p['beta'].value G = p['G'].value n = p['n'].value index = len(real[0]) - 1 #print index if real[1][index] - real[3][index] <= 0: return unitmae, unitrmse if kind == 0: res = SIRd.SI(beta, G, n, index + 1) if kind == 1: gamma = p['gamma'].value res = SIRd.SIRd(gamma, 0, beta, G, n, index + 1) if kind == 2: gamma = p['gamma'].value alpha = p['alpha'].value res = SIRd.SIRd(gamma, alpha, beta, G, n, index + 1) if kind == 3: gamma = p['gamma'].value alpha = p['alpha'].value lambdaval = p['lambdaval'].value deltaval = p['delta'].value res = SIRd.SIRdecayImpulse(gamma, alpha, beta, G, n, index + 1, lambdaval, deltaval) if kind == 4: gamma = p['gamma'].value alpha = p['alpha'].value lambdaval = list() deltaval = list() count = 0 while 2 * (count + 1) + 5 <= len(p): lambdaval.append(p['lambdaval' + str(count)].value) deltaval.append(p['delta' + str(count)].value) count += 1 res = SIRd.SIRdecayMultiImpulse(gamma, alpha, beta, G, n, index + 1, lambdaval, deltaval) #print index #print len(res[0]) temp = abs(res[0][index] - real[1][index]) unitmae.append(temp) temp = temp * 1.0 / real[1][index] unitrmse.append(temp) temp = abs(res[1][index] - (real[1][index] - real[3][index])) unitmae.append(temp) temp = temp * 1.0 / (real[1][index] - real[3][index]) unitrmse.append(temp) temp = abs(res[2][index] - real[3][index]) unitmae.append(temp) if real[3][index] != 0: temp = temp * 1.0 / real[3][index] unitrmse.append(temp) return unitmae, unitrmse
def getCurve(p, flag, steps): p = [float(k) for k in p] cnt = 5 l = list() d = list() while cnt < len(p): l.append(p[cnt]) d.append(p[cnt + 1]) cnt += 2 t = SIRd.SIRdecayMultiImpulse(p[2], p[0], p[1], p[3], p[4], steps, l, d) s = [k / p[3] for k in t[flag]] return t[flag], s
def params2fcnval(params,nsteps,mode): beta=params['beta'].value G=params['G'].value n=params['n'].value if mode == 5: eps = params['eps'].value res = SIRd.SpikeM(beta, G, n nsteps, eps) return res if mode == 4: res = SIRd.SI(beta, G, n, nsteps) return res gamma=params['gamma'].value if mode == 3: res = SIRd.SIRd(gamma, 0, beta, G, n, nsteps) return res alpha=params['alpha'].value if mode == 2: res = SIRd.SIRd(gamma, alpha, beta, G, n, nsteps) return res lambdaval=params['lambdaval'].value deltaval=params['delta'].value res=SIRd.SIRdecayImpulse(gamma,alpha,beta,G,n,nsteps,lambdaval,deltaval) return res
def params2fcnvalMulti(params,nsteps,peaks): beta=params['beta'].value alpha=params['alpha'].value gamma=params['gamma'].value G=params['G'].value n=params['n'].value lambdaval=list() deltaval=list() for i in range(peaks): if len(params) - 5 < 2 * (i + 1): break lambdaval.append(params['lambdaval'+str(i)].value) deltaval.append(params['delta'+str(i)].value) #nsteps=x.max()+1 res=SIRd.SIRdecayMultiImpulse(gamma,alpha,beta,G,n,nsteps,lambdaval,deltaval) return res
def getCurve(p, flag, steps): p = [float(k) for k in p] t = SIRd.SIRd(p[2], p[0], p[1], p[3], p[4], steps) s = [k / p[3] for k in t[flag]] return t[flag], s
def getCurve(p, flag, steps): p = [float(k) for k in p] t = SIRd.SIRdecayImpulse(p[2], p[0], p[1], p[3], p[4], steps, p[5], p[6]) s = [k/p[3] for k in t[flag]] return t[flag], s