@@ -21,7 +21,7 @@ import edu.berkeley.bid.CUMACH
2121 *
2222 * - In particular, we need \Delta* and Var(\Delta*). Since \Delta* is of the form:
2323 *
24- * \Delta* = - log(u) + (1/b)\sum_{i=1}^b Y_i
24+ * \Delta* = -\psi + (1/b)\sum_{i=1}^b Y_i
2525 *
2626 * for IID random variables Y_i, which represent a log of a probability ratio,
2727 * it suffices to compute the statistics as follows:
@@ -61,7 +61,7 @@ class MHTest(override val opts:MHTest.Opts = new MHTest.Options) extends Updater
6161 var b : Long = 0 // Current minibatch size (also `b` in the paper).
6262 var N : Long = 0 // Maximum minibatch size (i.e. all training data).
6363 var n : Float = 0f // The *number* of minibatches we are using.
64- var logu : Float = 0f // log u, since we assume a symmetric proposer.
64+ var psi : Float = 0f // \psi = log (1 * prop_ratio * prior_ratio)
6565 var T : Int = 1 // The temperature of the distribution.
6666 var t : Int = 0 // Current number of samples of theta.
6767 var sumOfValues : Float = 0f // \sum_{i=1}^b (N/T)*log(p(x_i|theta')/p(x_i|theta)).
@@ -148,7 +148,7 @@ class MHTest(override val opts:MHTest.Opts = new MHTest.Options) extends Updater
148148 // (Part 2) Update our \Delta* and sample variance of \Delta*.
149149 sumOfSquares += sum((diff)*@ (diff)).v
150150 sumOfValues += sum(diff).v
151- val deltaStar = sumOfValues/ b.v - logu
151+ val deltaStar = sumOfValues/ b.v - psi
152152 val sampleVariance = (sumOfSquares/ b.v - ((sumOfValues/ b.v)* (sumOfValues/ b.v))) / b.v
153153 val numStd = deltaStar / math.sqrt(sampleVariance)
154154 var accept = false
@@ -221,7 +221,7 @@ class MHTest(override val opts:MHTest.Opts = new MHTest.Options) extends Updater
221221 def beforeEachMinibatch () {
222222 if (opts.verboseMH) println(" \n\t New minibatch!" )
223223 randomWalkProposer()
224- logu = ln(rand( 1 , 1 )).v
224+ psi = ln(1 ).v // WARNING, symmetric proposals ONLY, since \psi(1,\theta,theta')=0.
225225 newMinibatch = false
226226 b = 0
227227 n = 0
@@ -313,7 +313,7 @@ class MHTest(override val opts:MHTest.Opts = new MHTest.Options) extends Updater
313313
314314 /** This is for debugging. */
315315 def debugPrints (sampleVariance: Float , deltaStar: Float ) {
316- println(" b=" + b+ " , n=" + n+ " , logu =" + logu + " , b-mbSize=" + (b - model.datasource.opts.batchSize).toInt)
316+ println(" b=" + b+ " , n=" + n+ " , psi =" + psi + " , b-mbSize=" + (b - model.datasource.opts.batchSize).toInt)
317317 println(" mean(scores0) = " + mean(scores0,2 ).dv+ " , mean(scores1) = " + mean(scores1,2 ).dv)
318318 println(" sampleVar = " + sampleVariance)
319319 println(" delta* = " + deltaStar)
0 commit comments