def moment_dice_metric(x, y, **kwargs): """ kwargs: fourthmoment - True/False. False by detault """ nx = float(len(x)) ny = float(len(y)) Exi = x.mean() sigmaxi = math.pow(moment(x, 2), 1 / 2.0) #central_moment(x, Exi, 2) sxi = math.pow(abs(moment(x, 3)), 1 / 3.0) #central_moment(x, Exi, 3) kxi = math.pow(moment(x, 4), 1 / 4.0) #central_moment(x, Exi, 4) Eyi = y.mean() sigmayi = math.pow(moment(y, 2), 1 / 2.0) #central_moment(y, Eyi, 2) syi = math.pow(abs(moment(y, 3)), 1 / 3.0) #central_moment(y, Eyi, 3) kyi = math.pow(moment(y, 4), 1 / 4.0) #central_moment(y, Eyi, 4) fourthmoment = False if "fourthmoment" in kwargs: fourthmoment = kwargs["fourthmoment"] if fourthmoment == True: fx1 = np.array([Exi, sigmaxi, sxi, kxi]) fy1 = np.array([Eyi, sigmayi, syi, kyi]) else: fx1 = np.array([Exi, sigmaxi, sxi]) fy1 = np.array([Eyi, sigmayi, syi]) return dice(fx1, fy1)
def moment_dice_metric(x, y, **kwargs): """ kwargs: fourthmoment - True/False. False by detault """ nx = float(len(x)) ny = float(len(y)) Exi = x.mean() sigmaxi = math.pow(moment(x, 2), 1 / 2.0) # central_moment(x, Exi, 2) sxi = math.pow(abs(moment(x, 3)), 1 / 3.0) # central_moment(x, Exi, 3) kxi = math.pow(moment(x, 4), 1 / 4.0) # central_moment(x, Exi, 4) Eyi = y.mean() sigmayi = math.pow(moment(y, 2), 1 / 2.0) # central_moment(y, Eyi, 2) syi = math.pow(abs(moment(y, 3)), 1 / 3.0) # central_moment(y, Eyi, 3) kyi = math.pow(moment(y, 4), 1 / 4.0) # central_moment(y, Eyi, 4) fourthmoment = False if "fourthmoment" in kwargs: fourthmoment = kwargs["fourthmoment"] if fourthmoment == True: fx1 = np.array([Exi, sigmaxi, sxi, kxi]) fy1 = np.array([Eyi, sigmayi, syi, kyi]) else: fx1 = np.array([Exi, sigmaxi, sxi]) fy1 = np.array([Eyi, sigmayi, syi]) return dice(fx1, fy1)
def simexp(nvars): nvar1 = nvars[0] nvar2 = nvars[1] r = SystemRandom() npr.seed(r.randint(0, 1e15)) x = npr.exponential(30, nvar1) npr.seed(r.randint(0, 1e15)) y = npr.exponential(35, nvar2) if False: x.sort() y.sort() darray = np.zeros(100) for i in xrange(0, 100): yprime = r.sample(y, len(x)) yprime.sort() darray[i] = util.dice(x, yprime) return max_conf_est(darray, 0.99) return new_similarity_invcdf(x, y)
def simpareto(nvars): nvar1 = nvars[0] nvar2 = nvars[1] p1 = Pareto(2000.0, 2.0) p2 = Pareto(2000.0, 1.0) x = p1.rnd(nvar1) y = p2.rnd(nvar2) x.sort() y.sort() if False: r = SystemRandom() darray = np.zeros(100) for i in xrange(0, 100): yprime = r.sample(y, len(x)) darray[i] = util.dice(x, yprime) return max_conf_est(darray, 0.99) return new_similarity_invcdf(x, y)
def simpareto(nvars): nvar1 = nvars[0] nvar2 = nvars[1] p1 = Pareto(2000.0, 2.0) p2 = Pareto(2000.0, 1.0) x = p1.rnd(nvar1) y = p2.rnd(nvar2) x.sort() y.sort() if False: r = SystemRandom() darray = np.zeros(100) for i in xrange(0,100): yprime = r.sample(y, len(x)) darray[i] = util.dice(x,yprime) return max_conf_est(darray, 0.99) return new_similarity_invcdf(x, y)
def simexp(nvars): nvar1 = nvars[0] nvar2 = nvars[1] r = SystemRandom() npr.seed(r.randint(0,1e15)) x = npr.exponential(30, nvar1) npr.seed(r.randint(0,1e15)) y = npr.exponential(35,nvar2) if False: x.sort() y.sort() darray = np.zeros(100) for i in xrange(0,100): yprime = r.sample(y, len(x)) yprime.sort() darray[i] = util.dice(x,yprime) return max_conf_est(darray, 0.99) return new_similarity_invcdf(x,y)
def dice_matrix(mname): global CAT fa = str(mname) + "." + CAT[0] fm = str(mname) + "." + CAT[1] fd = str(mname) + "." + CAT[2] fh = str(mname) + "." + CAT[3] a = read_data(fa) m = read_data(fm) d = read_data(fd) h = read_data(fh) a.sort() m.sort() d.sort() h.sort() am = dice(a,m,issorted=True) ad = dice(a,d,issorted=True) ah = dice(a,h,issorted=True) md = dice(m,d,issorted=True) mh = dice(m,h,issorted=True) dh = dice(d,h,issorted=True) simmat = np.zeros([4,4]) simmat[0,0] = ah simmat[0,1] = ad simmat[0,2] = am simmat[1,0] = mh simmat[1,1] = md simmat[2,0] = dh return simmat
def dice_matrix(mname): global CAT fa = str(mname) + "." + CAT[0] fm = str(mname) + "." + CAT[1] fd = str(mname) + "." + CAT[2] fh = str(mname) + "." + CAT[3] a = read_data(fa) m = read_data(fm) d = read_data(fd) h = read_data(fh) a.sort() m.sort() d.sort() h.sort() am = dice(a, m, issorted=True) ad = dice(a, d, issorted=True) ah = dice(a, h, issorted=True) md = dice(m, d, issorted=True) mh = dice(m, h, issorted=True) dh = dice(d, h, issorted=True) simmat = np.zeros([4, 4]) simmat[0, 0] = ah simmat[0, 1] = ad simmat[0, 2] = am simmat[1, 0] = mh simmat[1, 1] = md simmat[2, 0] = dh return simmat
def cdf_dice_metric(x, y): x.sort() y.sort() (x12, f1, f2) = comb_cdf(x, y, issorted=True) return dice(f1, f2)