def plikelihood(self): (x, y), (h, w), a = self.det det = np.floor(np.array([[x, y, h, w]])) yrep = np.ones((self.num_p, 4)) * det R2 = np.sum(np.power(self.p - yrep, 2), 1) width = 2 * (np.amax(np.sqrt(R2)) - np.amin(np.sqrt(R2))) prob = np.exp(-R2 / width) prob = prob / np.sum(prob) self.prob = prob self.sortprob()
def pmfrnd(self): x = np.arange(self.num_p) dist = np.cumsum(self.prob) rndnum = np.random.rand() k = np.sum(rndnum > dist) return x[k]
def plikelihood(self): if self.update: (x, y), (h, w), a = self.rb det = np.floor(np.array([[x, y, h, w, x - self.p_star[0], y - self.p_star[1]]])) yrep = np.ones((self.num_p, 6)) * det R2 = np.sum(np.power(self.p[:, 0:6] - yrep, 2), 1) width = 2 * (np.amax(np.sqrt(R2)) - np.amin(np.sqrt(R2))) prob = np.exp(- R2 / width) a = np.sum(prob) if a != 0.0: prob = prob / np.sum(prob) self.prob = prob self.sortprob() self.calculatepstar()
def plikelihood(self): if self.update: (x, y), (h, w), a = self.rb det = np.floor( np.array([[x, y, h, w, x - self.p_star[0], y - self.p_star[1]]])) yrep = np.ones((self.num_p, 6)) * det R2 = np.sum(np.power(self.p[:, 0:6] - yrep, 2), 1) width = 2 * (np.amax(np.sqrt(R2)) - np.amin(np.sqrt(R2))) prob = np.exp(-R2 / width) a = np.sum(prob) if a != 0.0: prob = prob / np.sum(prob) self.prob = prob self.sortprob() self.calculatepstar()
def resample(self): if np.sum(self.prob) > 0: p = self.p y, x = p.shape new_p = np.zeros((y, x)) for ii in range(len(self.p)): idx = self.pmfrnd() new_p[ii, :] = p[idx, :] self.p = new_p
def plikelihood_new(self): if self.update: (x, y), (h, w), a = self.rb detectionExtended = np.floor(np.array([[x, y, h, w, x - self.p_star[0], y - self.p_star[1]]])) yrep = np.ones((self.num_p, 6)) * detectionExtended prob = gaussMixModelPDF(oneParticle,detectionExtended,p_star) R2 = np.sum(np.power(self.p[:, 0:6] - yrep, 2), 1) width = 2 * (np.amax(np.sqrt(R2)) - np.amin(np.sqrt(R2))) prob = np.exp(- R2 / width) a = np.sum(prob) if a != 0.0: prob = prob / np.sum(prob) self.prob = prob self.sortprob() self.calculatepstar()
def plikelihood_new(self): if self.update: (x, y), (h, w), a = self.rb detectionExtended = np.floor( np.array([[x, y, h, w, x - self.p_star[0], y - self.p_star[1]]])) yrep = np.ones((self.num_p, 6)) * detectionExtended prob = gaussMixModelPDF(oneParticle, detectionExtended, p_star) R2 = np.sum(np.power(self.p[:, 0:6] - yrep, 2), 1) width = 2 * (np.amax(np.sqrt(R2)) - np.amin(np.sqrt(R2))) prob = np.exp(-R2 / width) a = np.sum(prob) if a != 0.0: prob = prob / np.sum(prob) self.prob = prob self.sortprob() self.calculatepstar()
def calculatepstar(self): if np.sum(self.prob) != 0: self.p_star = np.average(self.p, axis = 0, weights = self.prob) else: self.p_star = np.average(self.p, axis = 0)
def calculatepstar(self): if np.sum(self.prob) != 0: self.p_star = np.average(self.p, axis=0, weights=self.prob) else: self.p_star = np.average(self.p, axis=0)