DistanceMatcher

class leuvenmapmatching.matcher.distance.DistanceMatcher(*args, **kwargs)[source]

Map Matching that takes into account the distance between matched locations on the map compared to the distance between the observations (that are matched to these locations). It thus prefers matched paths that have a similar distance than the observations.

Inspired on the method presented in:

P. Newson and J. Krumm. Hidden markov map matching through noise and sparseness. In Proceedings of the 17th ACM SIGSPATIAL international conference on advances in geographic information systems, pages 336–343. ACM, 2009.

The options available in :class:BaseMatcher are inherited. Additionally, this class offers:

  • Transition probability is lower if the distance between observations and states is different
  • Transition probability is lower if the the next match is going back on an edge or to a previous edge
  • Transition probability is lower if two neighboring states represent not connected edges
  • Skip non-emitting states if distance between states and observations is close to each other

Create a new object.

Parameters:
  • map_con – Map object to connect to map database
  • obs_noise – Standard deviation of noise
  • obs_noise_ne – Standard deviation of noise for non-emitting states (is set to obs_noise if not given)
  • max_dist_init – Maximum distance from start location (if not given, uses max_dist)
  • max_dist – Maximum distance from path (this is a hard cut, min_prob_norm should be better)
  • min_prob_norm – Minimum normalized probability of observations (ema)
  • non_emitting_states – Allow non-emitting states. A non-emitting state is a state that is not associated with an observation. Here we assume it can be associated with a location in between two observations to allow for pruning. It is advised to set min_prob_norm and/or max_dist to avoid visiting all possible nodes in the graph.
  • non_emitting_length_factor – Reduce the probability of a sequence of non-emitting states the longer it is. This can be used to prefer shorter paths. This is separate from the transition probabilities because transition probabilities are averaged for non-emitting states and thus the length is also averaged out.
  • max_lattice_width – Restrict the lattice (or possible candidate states per observation) to this value. If there are more possible next states, the states with the best likelihood so far are selected.
  • dist_noise – Standard deviation of difference between distance between states and distance between observatoins. If not given, set to obs_noise
  • dist_noise_ne – If not given, set to dist_noise
  • restrained_ne – Avoid non-emitting states if the distance between states and between observations is close to each other.
  • avoid_goingback – If true, the probability is lowered for a transition that returns back to a previous edges or returns to a position on an edge.
  • args – Arguments for BaseMatcher
  • kwargs – Arguments for BaseMatcher
logprob_obs(dist, prev_m=None, new_edge_m=None, new_edge_o=None, is_ne=False)[source]

Emission probability for emitting states.

Exponential family: \(P(dt) = exp(-d_o^2 / (2 * obs_{noise}^2))\)

with \(d_o = |loc_{state} - loc_{obs}|\)

logprob_trans(prev_m, edge_m, edge_o, is_prev_ne=False, is_next_ne=False)[source]

Transition probability.

The probability is defined with a formula from the exponential family. \(P(dt) = exp(-d_t^2 / (2 * dist_{noise}^2))\)

with \(d_t = |d_s - d_o|, d_s = |loc_{prev\_state} - loc_{cur\_state}|, d_o = |loc_{prev\_obs} - loc_{cur\_obs}|\)

This function is more tolerant for low values. The intuition is that values under a certain distance should all be close to probability 1.0.

Note: We should also smooth the distance between observations to handle outliers better.

Parameters:
  • prev_m – Previous matching / state
  • edge_m – Edge between matchings / states
  • edge_o – Edge between observations
  • is_prev_ne – Is previous state non-emitting
  • is_next_ne – Is the next state non-emitting
  • dist_o – First output of distance_progress
  • dist_m – Second output of distance_progress
Returns: