How to use corner - 10 common examples

To help you get started, we’ve selected a few corner examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GalacticDynamics-Oxford / Agama / pytests / gc_runfit.py View on Github external
'''
        ndim = chain.shape[2]
        fig,axes = matplotlib.pyplot.subplots(ndim+1, 1, sharex=True, figsize=(20,15))
        for i in range(ndim):
            axes[i].plot(chain[:,:,i].T, color='k', alpha=0.5)
            axes[i].set_ylabel(self.model.labels[i])
        # last panel shows the evolution of log-likelihood for the ensemble of walkers
        axes[-1].plot(loglike.T, color='k', alpha=0.5)
        axes[-1].set_ylabel('log(L)')
        maxloglike = numpy.max(loglike)
        axes[-1].set_ylim(maxloglike-3*ndim, maxloglike)   # restrict the range of log-likelihood arount its maximum
        fig.tight_layout(h_pad=0.)
        matplotlib.pyplot.savefig(self.filename+"_chain.png")

        try:
            corner.corner(chain[-nsteps_mcmc:].reshape((-1, chain.shape[2])), \
                quantiles=[0.16, 0.5, 0.84], labels=labels)
            matplotlib.pyplot.savefig(self.filename+"_posterior.png")
        except ValueError as err:
            print "Can't plot posterior distribution:", err
github dfm / corner.py / tests.py View on Github external
def _run_hist2d(nm, N=50000, seed=1234, **kwargs):
    print(" .. {0}".format(nm))

    if not os.path.exists(FIGURE_PATH):
        os.makedirs(FIGURE_PATH)

    # Generate some fake data.
    np.random.seed(seed)
    x = np.random.randn(N)
    y = np.random.randn(N)

    fig, ax = pl.subplots(1, 1, figsize=(8, 8))
    corner.hist2d(x, y, ax=ax, **kwargs)
    fig.savefig(os.path.join(FIGURE_PATH, "hist2d_{0}.png".format(nm)))
    pl.close(fig)
github dfm / corner.py / tests / test_hist2d.py View on Github external
def _run_hist2d(nm, N=50000, seed=1234, **kwargs):
    # Generate some fake data.
    np.random.seed(seed)
    x = np.random.randn(N)
    y = np.random.randn(N)

    fig, ax = pl.subplots(1, 1, figsize=(8, 8))
    corner.hist2d(x, y, ax=ax, **kwargs)
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_weighted_quantile(seed=42):
    np.random.seed(seed)
    x = np.random.rand(25)
    q = np.arange(0.1, 1.0, 0.111234)
    a = corner.quantile(x, q, weights=np.ones_like(x))
    b = np.percentile(x, 100 * np.array(q))
    assert np.allclose(a, b)

    q = [0.0, 1.0]
    a = corner.quantile(x, q, weights=np.random.rand(len(x)))
    assert np.allclose(a, (np.min(x), np.max(x)))
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_invalid_quantiles_1(seed=42):
    np.random.seed(seed)
    with pytest.raises(ValueError):
        corner.quantile(np.random.rand(100), [-0.1, 5])
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_invalid_quantiles_2(seed=42):
    np.random.seed(seed)
    with pytest.raises(ValueError):
        corner.quantile(np.random.rand(100), 5)
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_dimension_mismatch(seed=42):
    np.random.seed(seed)
    with pytest.raises(ValueError):
        corner.quantile(
            np.random.rand(100), [0.1, 0.5], weights=np.random.rand(3)
        )
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_valid_quantile(seed=42):
    np.random.seed(seed)
    x = np.random.rand(25)
    q = np.arange(0.1, 1.0, 0.111234)

    a = corner.quantile(x, q)
    b = np.percentile(x, 100 * q)
    assert np.allclose(a, b)
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_invalid_quantiles_3(seed=42):
    np.random.seed(seed)
    with pytest.raises(ValueError):
        corner.quantile(np.random.rand(100), [0.5, 1.0, 8.1])
github dfm / corner.py / tests / test_quantile.py View on Github external
def test_weighted_quantile(seed=42):
    np.random.seed(seed)
    x = np.random.rand(25)
    q = np.arange(0.1, 1.0, 0.111234)
    a = corner.quantile(x, q, weights=np.ones_like(x))
    b = np.percentile(x, 100 * np.array(q))
    assert np.allclose(a, b)

    q = [0.0, 1.0]
    a = corner.quantile(x, q, weights=np.random.rand(len(x)))
    assert np.allclose(a, (np.min(x), np.max(x)))

corner

Make some beautiful corner plots

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

69 / 100
Full package analysis