MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / compute_ess

Function compute_ess

tensorflow/contrib/eager/python/examples/l2hmc/main.py:198–213  ·  view source on GitHub ↗

Compute the effective sample size based on autocorrelation spectrum. This follows equation 16 from the L2HMC paper. Args: ac_spectrum: Autocorrelation spectrum Returns: The effective sample size

(ac_spectrum)

Source from the content-addressed store, hash-verified

196
197
198def compute_ess(ac_spectrum):
199 """Compute the effective sample size based on autocorrelation spectrum.
200
201 This follows equation 16 from the L2HMC paper.
202
203 Args:
204 ac_spectrum: Autocorrelation spectrum
205 Returns:
206 The effective sample size
207 """
208 # Cutoff from the first value less than 0.05
209 cutoff = np.argmax(ac_spectrum[1:] < .05)
210 if cutoff == 0:
211 cutoff = len(ac_spectrum)
212 ess = 1. / (1. + 2. * np.sum(ac_spectrum[1:cutoff]))
213 return ess
214
215
216if __name__ == "__main__":

Callers 1

mainFunction · 0.85

Calls 2

argmaxMethod · 0.80
sumMethod · 0.45

Tested by

no test coverage detected