def calcNodeDriftVector(self): """ calculates the drift vector of a node. """ self.weightEstimate = 1.0 self.ratioW = self.weightEstimate/self.weight # compute statistics delta vector. # delta = (weight*localStatistics - weightEstimate*localEstimate - # (weight - weightEstimate)*globalEstimate) / weight self.cm.delta = VectorOps.multAndAdd(self.cm.localStatistics, \ self.weight, self.localEstimate) VectorOps.multAndAddTo(self.cm.delta, self.ratioW-self.weight,\ self.cm.globalV) # update drift vector VectorOps.cpy(self.cm.drift, self.cm.globalV) VectorOps.addTo(self.cm.drift, self.cm.delta) VectorOps.multAndAddTo(self.cm.drift, 1.0/self.weight, self.cm.slack)
def testDeepCpy(self): """ tests if new vector is really different """ self.cpy_vector = [] self.cpy_vector = VectorOps.cpy(self.cpy_vector, self.target) # change the target vector a little self.target = [1, 2, 1, 1, 1] self.assertIsNot(self.cpy_vector, self.target)
def calcNodeDriftVector(self): """ calculates the drift vector of a node. """ self.weightEstimate = 1.0 self.ratioW = self.weightEstimate / self.weight # compute statistics delta vector. # delta = (weight*localStatistics - weightEstimate*localEstimate - # (weight - weightEstimate)*globalEstimate) / weight self.cm.delta = VectorOps.multAndAdd(self.cm.localStatistics, \ self.weight, self.localEstimate) VectorOps.multAndAddTo(self.cm.delta, self.ratioW-self.weight,\ self.cm.globalV) # update drift vector VectorOps.cpy(self.cm.drift, self.cm.globalV) VectorOps.addTo(self.cm.drift, self.cm.delta) VectorOps.multAndAddTo(self.cm.drift, 1.0 / self.weight, self.cm.slack)
def testCpy(self): """ tests if new vector has some value inside it. """ self.cpy_vector = [] self.cpy_vector = VectorOps.cpy(self.cpy_vector, self.target) self.assertTrue(self.cpy_vector)