def main():
    Z, hopfield = create_ground_truth()
    d = hopfield.dimension
    
    print("Number of ground truth samples: %d" % len(Z))

    num_iterations = 200000
    warm_up = 1000
    thin = 100
    
    start = randint(0, 2, d).astype(numpy.bool8)
    timestring = time.strftime("%Y-%m-%d_%H:%M:%S")

    print("Running SM for %d iterations" % num_iterations)
    sm_chain = run_sm_chain(hopfield, start, num_iterations)
    try:
        fname = "temp_sm_result_" + timestring + ".bin"
        f = open(fname, "w")
        dump(sm_chain, f)
        f.close()
    except IOError:
        print("Could not save this SM chain")

    print("Running Gibbs for %d iterations" % (num_iterations * d))
    gibbs_chain = run_gibbs_chain(hopfield, start, num_iterations)
    try:
        fname = "temp_gibbs_result_" + timestring + ".bin"
        f = open(fname, "w")
        dump(gibbs_chain, f)
        f.close()
    except IOError:
        print("Could not save this Gibbs chain")
    
    print("Running Discrete Kameleon for %d iterations" % num_iterations)
    kameleon_chain = run_kameleon_chain(Z, hopfield, start, num_iterations)
    try:
        fname = "temp_kameleon_result_" + timestring + ".bin"
        f = open(fname, "w")
        dump(kameleon_chain, f)
        f.close()
    except IOError:
        print("Could not save this Kameleon chain")
    
    
    # remove warm up and thin
    print("Removing warm up and thinning")
    S_g = gibbs_chain.samples[warm_up:]
    S_g = S_g[arange(len(S_g), step=thin * d)].astype(numpy.bool8)
    S_k = kameleon_chain.samples[warm_up:]
    S_k = S_k[arange(len(S_k), step=thin)].astype(numpy.bool8)
    S_sm = sm_chain.samples[warm_up:]
    S_sm = S_sm[arange(len(S_sm), step=thin)].astype(numpy.bool8)
    print("Gibbs samples: %d" % len(S_g))
    print("Kameleon samples: %d" % len(S_k))
    print("SM samples: %d" % len(S_sm))
    
    
    print("MMDs:")
    kernel = HypercubeKernel(0.2)
    
    num_evaluations = 10
    inds_g = linspace(0, len(S_g), num_evaluations).astype(numpy.int)
    inds_k = linspace(0, len(S_k), num_evaluations).astype(numpy.int)
    inds_sm = linspace(0, len(S_sm), num_evaluations).astype(numpy.int)
    mmds = zeros((3, num_evaluations - 1))
    for i in arange(num_evaluations - 1):
        mmds[0, i - 1] = sqrt(kernel.estimateMMD(S_g[:inds_g[i + 1]], Z))
        mmds[1, i - 1] = sqrt(kernel.estimateMMD(S_k[:inds_k[i + 1]], Z))
        mmds[2, i - 1] = sqrt(kernel.estimateMMD(S_sm[:inds_sm[i + 1]], Z))
        
    
    print(mmds)
    plot(inds_g[1:], mmds[0, :])
    plot(inds_k[1:], mmds[1, :])
    plot(inds_sm[1:], mmds[2, :])
    legend(["Gibbs", "Kameleon", "SM"])
    show()
dataset/ETHPy150Open karlnapf/kameleon-mcmc/kameleon_mcmc/tests/discrete/initial_comparison_discrete.py/main/original