gns.calculations module

gns.calculations.Eoft2OverEoftPowi(nLive, i)[source]
gns.calculations.Eoft2Powi(nLive, i)[source]
gns.calculations.EoftPowi(nLive, i)[source]
gns.calculations.calc1mt(nLive, expectation='1mt', sampling=False, maxPoints=False)[source]

calc value of 1-t from its pdf, from (supposedely equivalent) way of deriving form of pdf, or from E[.] or E[l(.)]

gns.calculations.calc1mt2(nLive, expectation='1mt2', sampling=False, maxPoints=False)[source]

calc value of (1-t)^2 from its pdf, from (supposedely equivalent) way of deriving form of pdf, or from E[.] or E[l(.)]

gns.calculations.calcEofLogZ(EofZ, EofZ2, space='linear')[source]

calc E[log(Z)] from E[Z] and E[Z^2] or log(E[Z]) and log(E[Z^2]) as given in Will’s thesis (assumes Z log normal r.v.) NOTE in case of Keeton’s total value, won’t give correct result as won’t account for covariance between loop and final contributions

gns.calculations.calcEofLogZII(EofZ, varZ, space)[source]

Calc E[log(Z)] from E[Z] and Var[Z]. Assumes Z is log-normally distributed (taken from Wikipedia) Apart from for Keeton total (where variance doesn’t just come from E[Z] and E[Z^2] moments), should be same as first implementation

gns.calculations.calcEofZII(EofLogZ, varLogZ, space)[source]

calc E[Z] (log(E[Z])) from E[logZ] and var[logZ]. Assumes Z is log-normal (taken from Wikipedia)

gns.calculations.calcEofftArr(Eofft, nLive, n)[source]

Calculates E[f(t)]^i then returns this with yield. Yield means next time function is called, it picks off from where it last returned, with same variable values as before returning. Note the function isn’t executed until the generator return by yield is iterated over Putting for loop here is faster than filling in blank array

gns.calculations.calcEofts(nLive)[source]

calculate expected values of t related variables to update Z and X moments

gns.calculations.calcHSkillingK(EofZ, varZ, nLive)[source]

Uses definition of error given in Skilling’s NS paper, ACCORDING to Keeton. Only valid in limit that Skilling’s approximation of var[log(Z)] = H / nLive being correct, and E[Z]^2 >> var[Z] so that log(1+x)~x approximation is valid. Also requires that Z is log-normally distributed I think this is only valid for NS loop contributions, not final part or total

gns.calculations.calcLogEofts(nLive)[source]

Calculate log(E[t] - E[t^2]) as it is much easier to do so here than later having on log(E[t]) and log(E[t^2])

gns.calculations.calcLogVarZSkillingK(logEofZ, nLive, H)[source]

As above but working in log[*] space

gns.calculations.calcVarLogZ(EofZ, EofZ2, space='linear')[source]

calc var[log(Z)] from E[Z] and E[Z^2] or log(E[Z]) and log(E[Z^2]) as given in Will’s thesis (assumes Z log normal r.v.) NOTE in case of Keeton’s total value, won’t give correct result as won’t account for covariance between loop and final contributions

gns.calculations.calcVarLogZII(EofZ, varZ, space, method='log-normal')[source]

Uses propagation of uncertainty formula or relationship between log-normal r.v.s and the normally distributed log of the log-normal r.v.s to calculate var[logZ] from EofZ and varZ (taken from Wikipedia) Apart from for Keeton total (where variance doesn’t just come from E[Z] and E[Z^2] moments), should be same as first implementation

gns.calculations.calcVarLogZSkilling(H, nLive)[source]

Skilling works in log space throughout, including calculating the moments of log(*) i.e. E[f(log(*))]. Thus he derives a value for the variance of log(Z), through his discussions of Poisson fluctuations whilst exploring the posterior.

gns.calculations.calcVarZII(varLogZ, EofLogZ, EofZ, space, method='log-normal')[source]

Uses propagation of uncertainty formula or relationship between log-normal r.v.s and the normally distributed log of the log-normal r.v.s to calculate var[Z] (log(var[Z])) from EofZ and varLogZ (taken from Wikipedia)

gns.calculations.calcVarZSkillingK(EofZ, nLive, H)[source]

Uses definition of error given in Skilling’s NS paper, ACCORDING to Keeton. Only valid in limit that Skilling’s approximation of var[log(Z)] = H / nLive being correct, and E[Z]^2 >> var[Z] so that log(1+x)~x approximation is valid. Also requires that Z is log-normally distributed I think this is only valid for NS loop contributions, not final part or total

gns.calculations.calcVariance(EofX, EofX2)[source]

Calculate second moment of X from first moment and raw second moment

gns.calculations.calcVarianceLog(logEofX, logEofX2)[source]

Calc log(var(X)) from log(E[X]) and log(E[X^2]) Does logsubtractexp manually, so doesn’t account for possible underflow issues with exponentiating like np.logaddexp() does, but this shouldn’t be an issue for the numbers involved here.

gns.calculations.calct(nLive, expectation='t', sampling=False, maxPoints=False)[source]

calc value of t from its pdf, from (supposedely equivalent) way of deriving form of pdf, or from E[.] or E[l(.)]

gns.calculations.calct2(nLive, expectation='t2', sampling=False, maxPoints=False)[source]

calc value of t^2 from its pdf, from (supposedely equivalent) way of deriving form of pdf, or from E[.] or E[l(.)]

gns.calculations.getEofftArr(Eofft, nLive, nest)[source]

faster than creating array of zeroes and looping over

gns.calculations.getLogEofWeight(logw, LLhood_im1, LLhood_i, trapezoidalFlag)[source]

calculates logw + log(f(L_im1, L_i)) where f(L_im1, L_i) = L_i for standard quadrature and f(L_im1, L_i) = (L_im1 + L_i) / 2. for the trapezium rule

gns.calculations.getLogEofXLogEofw(nLive, X)[source]

get increment (part of weight for posterior and evidence calculations) based on previous value of X, calculates latest X using t calculated from either expected value or sampling. Expected value can be of t (E[t]) or log(t) E[log(t)]. These are roughly the same for large nLive Sampling can take two forms: sampling from the pdf or taking the highest of U[0,1]^Nlive values (from which the pdf form is derived from), so they should in theory be the same.