def gen_ring(n, width, SEED=0): numpy.random.seed(SEED) i = 0 # uses rejections sampling T = numpy.zeros((n, 2)) while i < n: x = numpy.random.uniform(-1, 1) y = numpy.random.uniform(-1, 1) rad = (x**2 + y**2)**.5 if 1.0 - w < rad and rad < 1.0: T[i, 0] = x T[i, 1] = y i += 1 mi_est = mitu.mi(T[:, 0], T[:, 1], base=math.e) return T, mi_est
def gen_ring( n, width, SEED=0 ): numpy.random.seed(SEED) i = 0; # uses rejections sampling T = numpy.zeros( (n,2) ) while i < n: x = numpy.random.uniform(-1,1) y = numpy.random.uniform(-1,1) rad = (x**2 + y**2)**.5 if 1.0-w < rad and rad < 1.0: T[i,0] = x T[i,1] = y i += 1 mi_est = mitu.mi(T[:,0], T[:,1], base=math.e) return T, mi_est
def gen_correlated_data(n, rho): T = numpy.random.multivariate_normal([0, 0], [[1, rho], [rho, 1]], n) true_MI = -.5 * numpy.log(1 - rho * rho) external_mi = mitu.mi(T[:, 0], T[:, 1], base=math.e) return T, true_MI, external_mi
def gen_correlated_data(n, rho): T = numpy.random.multivariate_normal([0, 0], [[1, rho], [rho, 1]], n) true_MI = -0.5 * numpy.log(1 - rho * rho) external_mi = mitu.mi(T[:, 0], T[:, 1], base=math.e) return T, true_MI, external_mi