Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new function route_between() to calculate routes between two known locations #45

Open
ethanplunkett opened this issue Mar 17, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@ethanplunkett
Copy link
Contributor

Given two points in space and time, for example a tag location and later encounter of that tag, a new function, route_between() would generate synthetic routes that connect them based on the probabilities in the BirdFlow model. It could be called iteratively to generate routes among a larger set of recapture locations (route_among() ?). Only one public facing function is needed for both purposes.

From @dsheldon (slack):

The idea is pretty simple: treat the model as an HMM with hard observations that X1=x1 and XT=xt, then do standard HMM inference. The specific algorithm for sampling is called forward-filtering-backward-sampling, and Raphael used it in his recent paper.

From a graphical model perspective, another way to think about it is as an undirected graphical model. We start with the factors p(x2 | x1) p(x3 | x2) … p(X_{T} | X_{T-1}). This is a directed model so it is normalized (sums to one over all settings of x1, …, xT).
Add two “hard” factors which are delta functions at the observed values of x1 and xT. The model is no longer normalized/directed but it’s still a chain model when treated as an undirected graphical model, so we can still compute all the needed normalized distributions via message passing aka the forward-backward algorithm.

Another way to see it is this: using standard Markov chain computations we can compute p(xt | x1) for any t. To sample from the trajectory given x1 and xT, the first thing we would need to do is to sample from
p(x_{T-1} | x1, x_T)
= p(x_{T-1}, x_T | x_1)/p(x_T | x_1)
= p(x_{T-1} | x_1) p(x_T | x_{T-1}) / p(x_T | x_1)
All quantities in the final expression are easy to compute (and are exactly what would be computed in forward-filtering-backward-sampling).

@dsheldon walks through the implementation in the attached PDF.
BirdFlow Forward Filtering Backward Sampling.pdf

@Rafnuss provided a link to his implementation:
https://github.com/Rafnuss/GeoPressureR/blob/v3/R/graph_product.R#L17

@ethanplunkett ethanplunkett added the enhancement New feature or request label Mar 17, 2023
@ethanplunkett ethanplunkett self-assigned this Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant