def create_ground_truth():
    filename_chain = "chain.bin"
    filename_Z = "Z.bin"
    filename_hopfield = "hopfield.bin"
    
    try:
        f = open(filename_Z, "r")
        Z = load(f)
        f.close()
        
        f = open(filename_hopfield, "r")
        hopfield = load(f)
        f.close()
        print("Loaded existing ground truth samples and hopfield netword.")
    except IOError:
        print("No existing ground truth samples. Creating.")
        
        # the network to sample from
        try:
            f = open(filename_hopfield, "r")
            hopfield = load(f)
            f.close()
            d = hopfield.dimension
            print("Loaded hopfield network")
        except IOError:
            d = 50
            b = randn(d)
            V = randn(d, d)
            W = V + V.T
            fill_diagonal(W, zeros(d))
            hopfield = Hopfield(W, b)
        
        # dump hopfield network
        f = open(filename_hopfield, "w")
        dump(hopfield, f)
        f.close()
        
        # iterations
        num_iterations = 10000000
        warm_up = 100000
        thin = 2000
        
        current_state = [rand() < 0.5 for _ in range(d)]
        distribution = HopfieldFullConditionals(full_target=hopfield,
                                                current_state=current_state,
                                                schedule="random_permutation")
        mcmc_sampler = Gibbs(distribution)
#         spread = .0001
#         mcmc_sampler = StandardMetropolisDiscrete(hopfield, spread)
        
        mcmc_params = MCMCParams(start=asarray(current_state, dtype=numpy.bool8), num_iterations=num_iterations)
        chain = MCMCChain(mcmc_sampler, mcmc_params)
        
        chain.append_mcmc_output(StatisticsOutput(plot_times=True, lag=1000))
        # chain.append_mcmc_output(StoreChainOutput(".", lag=100000))
        
    #     chain.append_mcmc_output(DiscretePlottingOutput(plot_from=0, lag=100))
        chain.run()
        
        # dump chain
        try:
            f = open(filename_chain, "w")
            dump(chain, f)
            f.close()
        except IOError:
            print("Could not save MCMC chain")
        
        # warmup and thin
        Z = chain.samples[(warm_up):]
        Z = Z[arange(len(Z), step=thin)]
        Z = Z.astype(numpy.bool8)
        
        # dump ground truth samples
        try:
            f = open(filename_Z, "w")
            dump(Z, f)
            f.close()
        except IOError:
            print("Could not save Z")
    
    return Z, hopfield
dataset/ETHPy150Open karlnapf/kameleon-mcmc/kameleon_mcmc/tests/discrete/initial_comparison_discrete.py/create_ground_truth/original