Пример #1
0
    def score(self, x, y, x_prev, n):
        """
        Score a particular proposal 

        """
        x_det = x_prev['x'] + x_prev['xdot'] * self.DELTA_T
        y_det = x_prev['y'] + x_prev['ydot'] * self.DELTA_T

        score = 0.0
        nd = ssm.util.log_norm_dens
        score += nd(x['x'], x_det, self.POS_NOISE_STD**2)
        score += nd(x['y'], y_det, self.POS_NOISE_STD**2)

        score += nd(x['xdot'], x_prev['xdot'], self.VELOCITY_NOISE_STD**2)
        score += nd(x['ydot'], x_prev['ydot'], self.VELOCITY_NOISE_STD**2)

        score += util.log_vonmises_dens(x['phi'], x_prev['phi'],
                                        self.PHI_NOISE_STD**2)

        # now the theta likelihood is fun because it's like, the product
        # of two things

        t_o = x['theta'] - self.THETA_OFFSET
        tn_o = x_prev['theta'] - self.THETA_OFFSET
        score += nd(tn_o, t_o, self.THETA_DRIFT_SIZE)
        score += nd(tn_o, 0, self.THETA_ENVELOPE_SIZE)

        return score
Пример #2
0
    def score(self, x, y, x_prev, n):
        """
        Score a particular proposal 

        """
        candidate_points = self.cached_candidate_points(y, x_prev, n)

        MIX_COMP = len(candidate_points)
        if MIX_COMP == 0 or n > self.DEBUG_STOP_PROPOSING:
            return self.base_proposal.score(x, y, x_prev, n)

        score = 0.0
        nd = ssm.util.log_norm_dens
        scores = np.zeros(MIX_COMP)
        for mci, mc in enumerate(candidate_points):
            score = 0.0
            score += nd(x['x'], mc['x'], self.POS_STD**2)
            score += nd(x['y'], mc['y'], self.POS_STD**2)
            # FIXME shoudl be von mises
            score += util.log_vonmises_dens(x['phi'], mc['phi'],
                                            self.PHI_STD**2)
            scores[mci] = score
        const = np.ones(MIX_COMP) * np.log(1. / MIX_COMP)
        scores += const
        score_accum = scores[0]
        for s in scores[1:]:
            score_accum = np.logaddexp(score_accum, s)

        return score_accum
Пример #3
0
    def score_trans(self, x, xn, i):

        x_det = x["x"] + x["xdot"] * self.DELTA_T
        y_det = x["y"] + x["ydot"] * self.DELTA_T

        score = 0.0
        nd = ssm.util.log_norm_dens
        score += nd(xn["x"], x_det, self.POS_NOISE_STD ** 2)
        score += nd(xn["y"], y_det, self.POS_NOISE_STD ** 2)

        score += nd(xn["xdot"], x["xdot"], self.VELOCITY_NOISE_STD ** 2)
        score += nd(xn["ydot"], x["ydot"], self.VELOCITY_NOISE_STD ** 2)

        score += util.log_vonmises_dens(xn["phi"], x["phi"], self.PHI_NOISE_STD ** 2)

        # now the theta likelihood is fun because it's like, the product
        # of two things
        t_o = x["theta"] - self.THETA_OFFSET
        tn_o = xn["theta"] - self.THETA_OFFSET
        score += nd(tn_o, t_o, self.THETA_DRIFT_SIZE)
        score += nd(tn_o, 0, self.THETA_ENVELOPE_SIZE)

        # FIXME automatic validation of this somehow? generate a shit-ton
        # of samples and then measure marginals?
        return score
Пример #4
0
    def score(self, x, y, x_prev, n):
        """
        Score a particular proposal 

        """
        x_det = x_prev['x'] + x_prev['xdot'] * self.DELTA_T
        y_det = x_prev['y'] + x_prev['ydot'] * self.DELTA_T
        
        score = 0.0
        nd = ssm.util.log_norm_dens
        score += nd(x['x'], x_det, self.POS_NOISE_STD**2)
        score += nd(x['y'], y_det, self.POS_NOISE_STD**2)
        
        score += nd(x['xdot'], x_prev['xdot'], 
                                        self.VELOCITY_NOISE_STD**2)
        score += nd(x['ydot'], x_prev['ydot'], 
                                        self.VELOCITY_NOISE_STD**2)

        score += util.log_vonmises_dens(x['phi'], x_prev['phi'], 
                                        self.PHI_NOISE_STD**2)

        # now the theta likelihood is fun because it's like, the product
        # of two things

        t_o = x['theta'] - self.THETA_OFFSET
        tn_o = x_prev['theta'] - self.THETA_OFFSET
        score += nd(tn_o, t_o, self.THETA_DRIFT_SIZE) 
        score += nd(tn_o, 0, self.THETA_ENVELOPE_SIZE)


        return score
Пример #5
0
    def score(self, x, y, x_prev, n):
        """
        Score a particular proposal 

        """
        candidate_points = self.cached_candidate_points(y, x_prev, n)

        MIX_COMP = len(candidate_points)        
        if MIX_COMP == 0 or n > self.DEBUG_STOP_PROPOSING:
            return self.base_proposal.score(x, y, x_prev, n)
        
        score = 0.0
        nd = ssm.util.log_norm_dens
        scores = np.zeros(MIX_COMP)
        for mci, mc in enumerate(candidate_points):
            score = 0.0
            score += nd(x['x'], mc['x'], self.POS_STD**2)
            score += nd(x['y'], mc['y'], self.POS_STD**2)
            # FIXME shoudl be von mises
            score += util.log_vonmises_dens(x['phi'], 
                                            mc['phi'], self.PHI_STD**2)
            scores[mci] = score
        const = np.ones(MIX_COMP) * np.log(1./MIX_COMP)
        scores += const
        score_accum = scores[0]
        for s in scores[1:]:
            score_accum = np.logaddexp(score_accum, s)
            
        return score_accum
Пример #6
0
    def score_trans(self, x, xn, i):

        x_det = x['x'] + x['xdot'] * self.DELTA_T
        y_det = x['y'] + x['ydot'] * self.DELTA_T

        score = 0.0
        nd = ssm.util.log_norm_dens
        score += nd(xn['x'], x_det, self.POS_NOISE_STD**2)
        score += nd(xn['y'], y_det, self.POS_NOISE_STD**2)

        score += nd(xn['xdot'], x['xdot'], self.VELOCITY_NOISE_STD**2)
        score += nd(xn['ydot'], x['ydot'], self.VELOCITY_NOISE_STD**2)

        score += util.log_vonmises_dens(xn['phi'], x['phi'],
                                        self.PHI_NOISE_STD**2)

        # now the theta likelihood is fun because it's like, the product
        # of two things
        t_o = x['theta'] - self.THETA_OFFSET
        tn_o = xn['theta'] - self.THETA_OFFSET
        score += nd(tn_o, t_o, self.THETA_DRIFT_SIZE)
        score += nd(tn_o, 0, self.THETA_ENVELOPE_SIZE)

        # FIXME automatic validation of this somehow? generate a shit-ton
        # of samples and then measure marginals?
        return score