Carry out the forward-backward algorithm for the HMM implied by knowing the two parental haplotypes.

forward_backward_(x, p1, p2, d, p, lambda, epsilon, start, end)

Arguments

x

0-1 vector of length p giving the offspring haplotypes

p1

0-1 vector of length p giving one parental haplotype

p2

0-1 vector of length p giving the other parental haplotype

d

numberic vector of length p - 1 giving the distance between each site

p

length of the vector x

lambda

the recombination rate, a multiplier for the distance d

epsilon

the pointwise mutation rate

start

indexes of the subset of x to perform the computation (1 indexed)

end

indexes of the subset of x to perform the computation (1 indexed)

Value

p1_start: the probability that the latent state immediately before the specified window is 1, i.e. the offspring is being copied from p1.

p1_start_odd: probability of an odd number of recombinations given that the latent state immediately before the specified window is 1.

p2_start_odd: probability of an odd number of recombinations given that the latent state immediately before the specified window is 2.