def run_test(argsin): n_rows = args["num_rows"] n_iters = args["num_iters"] n_chains = args["num_chains"] ct_kernel = args["ct_kernel"] fig = pylab.figure(num=None, facecolor='w', edgecolor='k',frameon=False, tight_layout=True) plt = 0 data = {'x':[], 'sin':[], 'ring':[], 'dots':[]} xlims = dict() ylims = dict() for shape in shapes: plt += 1 data[shape] = gen_function[shape](n_rows) ax = pylab.subplot(n_chains+1,4,plt) pylab.scatter( data[shape][0], data[shape][1], s=10, color='blue', edgecolor='none', alpha=.2 ) # pylab.ylabel("X") # pylab.ylabel("Y") # pylab.title("%s original" % shape) ax.set_xticks([]) ax.set_yticks([]) pylab.suptitle( "Kernel %i" % ct_kernel) xlims[shape] = ax.get_xlim() ylims[shape] = ax.get_ylim() States = [] for chain in range(n_chains): print("chain %i of %i." % (chain+1, n_chains)) plt = 0 for shape in shapes: print("\tWorking on %s." % shape) plt += 1 T = data[shape] S = cc_state.cc_state(T, cctypes, ct_kernel=ct_kernel, distargs=distargs) S.transition(N=n_iters) T_chain = numpy.array(su.simple_predictive_sample(S, n_rows, [0,1], N=n_rows)) ax = pylab.subplot(n_chains+1,4,chain*4+4+plt) ax.set_xticks([]) ax.set_yticks([]) pylab.scatter( T_chain[:,0], T_chain[:,1], s=10, color='red', edgecolor='none', alpha=.2 ) pylab.xlim(xlims[shape]) pylab.ylim(ylims[shape]) # pylab.title("%s simulated (%i)" % (shape, chain)) print("Done.") pylab.show()
def run_test(argsin): n_rows = args["num_rows"] n_iters = args["num_iters"] n_chains = args["num_chains"] n_per_chain = int(float(n_rows) / n_chains) plt = 0 for shape in shapes: print "Shape: %s" % shape plt += 1 T_o = gen_function[shape](n_rows) T_i = [] for chain in range(n_chains): print "chain %i of %i" % (chain + 1, n_chains) S = cc_state.cc_state(T_o, cctypes, ct_kernel=1, distargs=distargs) S.transition(N=n_iters) T_i.extend( su.simple_predictive_sample(S, n_rows, [0, 1], N=n_per_chain)) T_i = numpy.array(T_i) ax = pylab.subplot(2, 4, plt) pylab.scatter(T_o[0], T_o[1], color='blue', edgecolor='none') pylab.ylabel("X") pylab.ylabel("Y") pylab.title("%s original" % shape) pylab.subplot(2, 4, plt + 4) pylab.scatter(T_i[:, 0], T_i[:, 1], color='red', edgecolor='none') pylab.ylabel("X") pylab.ylabel("Y") pylab.xlim(ax.get_xlim()) pylab.ylim(ax.get_ylim()) pylab.title("%s simulated" % shape) print "Done." pylab.show()
def run_test(argsin): n_rows = args["num_rows"] n_iters = args["num_iters"] n_chains = args["num_chains"] n_per_chain = int(float(n_rows) / n_chains) plt = 0 for shape in shapes: print "Shape: %s" % shape plt += 1 T_o = gen_function[shape](n_rows) T_i = [] for chain in range(n_chains): print "chain %i of %i" % (chain + 1, n_chains) S = cc_state.cc_state(T_o, cctypes, ct_kernel=1, distargs=distargs) S.transition(N=n_iters) T_i.extend(su.simple_predictive_sample(S, n_rows, [0, 1], N=n_per_chain)) T_i = numpy.array(T_i) ax = pylab.subplot(2, 4, plt) pylab.scatter(T_o[0], T_o[1], color="blue", edgecolor="none") pylab.ylabel("X") pylab.ylabel("Y") pylab.title("%s original" % shape) pylab.subplot(2, 4, plt + 4) pylab.scatter(T_i[:, 0], T_i[:, 1], color="red", edgecolor="none") pylab.ylabel("X") pylab.ylabel("Y") pylab.xlim(ax.get_xlim()) pylab.ylim(ax.get_ylim()) pylab.title("%s simulated" % shape) print "Done." pylab.show()
def run_test(argsin): n_rows = args["num_rows"] n_iters = args["num_iters"] n_chains = args["num_chains"] ct_kernel = args["ct_kernel"] fig = pylab.figure(num=None, facecolor='w', edgecolor='k', frameon=False, tight_layout=True) plt = 0 data = {'x': [], 'sin': [], 'ring': [], 'dots': []} xlims = dict() ylims = dict() for shape in shapes: plt += 1 data[shape] = gen_function[shape](n_rows) ax = pylab.subplot(n_chains + 1, 4, plt) pylab.scatter(data[shape][0], data[shape][1], s=10, color='blue', edgecolor='none', alpha=.2) # pylab.ylabel("X") # pylab.ylabel("Y") # pylab.title("%s original" % shape) ax.set_xticks([]) ax.set_yticks([]) pylab.suptitle("Kernel %i" % ct_kernel) xlims[shape] = ax.get_xlim() ylims[shape] = ax.get_ylim() States = [] for chain in range(n_chains): print("chain %i of %i." % (chain + 1, n_chains)) plt = 0 for shape in shapes: print("\tWorking on %s." % shape) plt += 1 T = data[shape] S = cc_state.cc_state(T, cctypes, ct_kernel=ct_kernel, distargs=distargs) S.transition(N=n_iters) T_chain = numpy.array( su.simple_predictive_sample(S, n_rows, [0, 1], N=n_rows)) ax = pylab.subplot(n_chains + 1, 4, chain * 4 + 4 + plt) ax.set_xticks([]) ax.set_yticks([]) pylab.scatter(T_chain[:, 0], T_chain[:, 1], s=10, color='red', edgecolor='none', alpha=.2) pylab.xlim(xlims[shape]) pylab.ylim(ylims[shape]) # pylab.title("%s simulated (%i)" % (shape, chain)) print("Done.") pylab.show()