@@ -0,0 +1,1724 @@
+import sys%0Aimport time%0Aimport numpy as np%0Afrom abcpy.core import *%0Afrom abcpy.distributions import *%0Afrom distributed import Client%0Afrom dask.dot import dot_graph%0Afrom functools import partial%0A%0Aimport matplotlib%0Aimport matplotlib.pyplot as plt%0A%0Adef normal_simu(n, mu, prng=None, latents=None):%0A    if latents is None:%0A        if prng is None:%0A            prng = np.random.RandomState()%0A        latents = prng.randn(n)%0A    u = mu + latents%0A    y = u%0A    return y%0A%0Adef mean(y):%0A    mu = np.mean(y, axis=1, keepdims=True)%0A    return mu%0A%0Adef distance(x, y):%0A    d = np.linalg.norm( np.array(x) - np.array(y), ord=2, axis=0)%0A    return d%0A%0Adef main():%0A    n = 1000%0A    mu = 1.6%0A%0A    # Set up observed data y%0A    latents = np.random.randn(n)%0A    y = normal_simu(n, mu, latents=latents)%0A%0A    # Plot%0A    plt.hist(y)%0A%0A    # Set up the simulator%0A    simulator = partial(normal_simu, n)%0A%0A    # Specify the graphical model%0A    mu = Prior('mu', 'uniform', 0, 4)%0A    Y = Simulator('normal_simu', simulator, mu, observed=y)%0A    S1 = Summary('S1', mean, Y)%0A    d = Discrepancy('d', distance, S1)%0A%0A    # Specify the number of simulations%0A    N = 1000000%0A%0A    # Time and run parallel%0A    s = time.time()%0A    dists = d.generate(N, batch_size=10000).compute()%0A%0A    print(%22Elapsed time %25d sec%22 %25 (time.time() - s))%0A%0A    # Take the parameters%0A    mu_sample = mu.generate(N).compute()%0A%0A    # Set threshold and reject to get posteriors%0A    eps = 0.01%0A    accepts = dists %3C eps%0A    mu_post = mu_sample%5Baccepts%5D%0A    print(%22Number of accepted samples %25d%22 %25 sum(accepts))%0A%0A    if len(mu_post) %3E 0:%0A        print(%22Posterior for mu%22)%0A        plt.hist(mu_post, bins=20)%0A    else:%0A        print(%22No accepted samples%22)%0A%0Aif __name__ == %22__main__%22:%0A    main()%0A

Add script variant of the Gauss example