def sim_mat(x, y): """ mtype: cdd, ks, dm3, dm4 """ """ cdd: combined CDF dice """ """ ks: combined CDF K-S """ """ dm3: dice with 3 moments, 1 moment and 2 central moments """ """ dm4: dice with 4 moments, 1 moment and 3 central moments """ global mtype sim_idx = float("NaN") try: if mtype == None or mtype == "ks": sim_idx = simple_ks(x, y) elif mtype == "cdd": sim_idx = cdf_dice_metric(x, y) elif mtype == "dm3": sim_idx = moment_dice_metric(x, y) elif mtype == "dm4": sim_idx = moment_dice_metric(x, y, fourthmoment=True) elif mtype == "nm": sim_idx = newmetric(x, y) elif mtype == "invcdf": sim_idx = new_similarity_invcdf(x, y) return sim_idx except BaseException, be: print "Exception -> ", be return float("NaN")
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 sim_mat(x, y, mtype): """ mtype: cdd, ks, dm3, dm4 """ """ cdd: combined CDF dice """ """ ks: combined CDF K-S """ """ dm3: dice with 3 moments, 1 moment and 2 central moments """ """ dm4: dice with 4 moments, 1 moment and 3 central moments """ sim_idx = 0.0 if mtype == None or mtype == "ks": sim_idx = simple_ks(x, y) elif mtype == "cdd": sim_idx = cdf_dice_metric(x, y) elif mtype == "dm3": sim_idx = moment_dice_metric(x, y) elif mtype == "dm4": sim_idx = moment_dice_metric(x, y, fourthmoment=True) elif mtype == "nm": sim_idx = newmetric(x, y) elif mtype == "sdice": sim_idx = simple_dice(x, y) elif mtype == "invcdf": sim_idx = new_similarity_invcdf(x, y) return sim_idx
def sim_mat(x,y,mtype): """ mtype: cdd, ks, dm3, dm4 """ """ cdd: combined CDF dice """ """ ks: combined CDF K-S """ """ dm3: dice with 3 moments, 1 moment and 2 central moments """ """ dm4: dice with 4 moments, 1 moment and 3 central moments """ sim_idx = 0.0 if mtype == None or mtype == "ks": sim_idx = simple_ks(x,y) elif mtype == "cdd": sim_idx = cdf_dice_metric(x,y) elif mtype == "dm3": sim_idx = moment_dice_metric(x,y) elif mtype == "dm4": sim_idx = moment_dice_metric(x,y,fourthmoment=True) elif mtype == "nm": sim_idx = newmetric(x,y) elif mtype == "sdice": sim_idx = simple_dice(x,y) elif mtype == "invcdf": sim_idx = new_similarity_invcdf(x,y) return sim_idx