コード例 #1
0
ファイル: ns.py プロジェクト: andrewfowlie/ns_for_p_values
def dynesty(test_statistic, transform, n_dim, observed, n_live=100, **kwargs):
    """
    Nested sampling with dynesty
    """
    sampler = NestedSampler(test_statistic,
                            transform,
                            n_dim,
                            nlive=n_live,
                            **kwargs)
    it = 0

    for it, state in enumerate(sampler.sample(dlogz=0.)):

        threshold = state[3]
        calls = state[9]

        if it % 100 == 0:
            log_convergence(threshold, observed)

        if threshold > observed:
            logging.info("threshold reached observed - stopping")
            break

    calls = sampler.results["ncall"].sum()
    n_iter = it + 1
    return Result.from_ns(n_iter, n_live, calls)
コード例 #2
0
            ),
            **init_sampler_kwargs,
        )
    else:
        sampler.prior_transform = prior_transform_function
        sampler.loglikelihood = log_likelihood_function
        sampler.evolve_point = sample_rwalk_parallel_with_act
        #sampler.sampling = sample_rwalk_parallel_with_act
        sampler.pool = pool
        sampler.M = pool.map
    logger.info(
        f"Starting sampling for job {label}, with pool size={POOL_SIZE} "
        f"and check_point_deltaT={check_point_deltaT}")

    sampler_kwargs = dict(dlogz=dlogz)
    for it, res in enumerate(sampler.sample(**sampler_kwargs)):

        (
            worst,
            ustar,
            vstar,
            loglstar,
            logvol,
            logwt,
            logz,
            logzvar,
            h,
            nc,
            worst_it,
            boundidx,
            bounditer,