Skip to content

Motivated choice for dlogz #423

Open
@segasai

Description

Currently dlogz and dlogz_init values are taken out of thin air pretty much and they are often set to 0.01. But there is a way of motivating their choice.

The rationale there is the following.
I'll assume we're sampling an N-dim Gaussian, with n live points and aim to have Neff samples. I'll also define as Z(r) as posterior volume within a ball radius r.

Given that we want $N_{eff}$ samples, we want our inner point in the samples to satisfy approximately $Z(r_{in}) = 1/N_{eff}$. In the same time, given the live-points are uniformly distributed,the radius of the outermost point is $r_{out}= n^{\frac{1}{N}} r_{in}$.
The remaining $\delta \log Z$ (in dynesty sense) for the outermost point is then $\log (1-Z(r_{out}))$.
Given that $Z(r) = IncGamma(\frac{N}{2}, \frac{r^2}{2})$ one can compute $\delta \log Z$ given $N_{eff}$, n live points and N dimensions.
Here is the code doing this calculation:

import scipy.optimize
import scipy.special
import numpy as np


def getdlogz(Neff, ndim, nlive):

    def func(r):
        # this is Z(r)  == 1/Neff eqn
        return scipy.special.gammainc(ndim / 2., r**2 / 2.) - 1 / Neff

    p0 = scipy.special.gamma(ndim / 2.)**(1. / ndim)
    ret = scipy.optimize.root(func, p0)
    r1 = ret.x[0]
    # this is the radius of the sphere corresponding to 1/neff=Z                
    r2 = r1 * (nlive**(1. / ndim))
    # this is the radius of outer most point if we have nlive uniform pts       
    ret = -np.log1p(-scipy.special.gammainc(ndim / 2., r2**2 / 2))
    # this is dlogz corresponding to the outermost point                        
    return ret

For example for ndim=4, nlive=100, neff=100 that gives dlogz=0.6
ndim=100, nlive=100, neff=100 that gives dlogz=0.04
ndim=10, nlive=100, neff=10000 gives dlogz =0.005

This is a motivation in terms of Neff. I haven't thought about motivation in terms of logz accuracy. But presumably if we cap the neff to be larger than 100 in the calculation above that will guarantee that our innermost point will correspond to Z_in/Z_tot = 0.01 which should be good enough for good logz accuracy.

Thoughts @joshspeagle ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    enhancementupgrades and improvementsquestionquestions about stuff

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions