# Bayesian formula with multiple events

#### anuket

##### New Member
I am trying to predict next location of the user knowing his current (t) and previous location (t-1). I am trying to use Bayesian networks for this.

Lets assume that we have following path: food (F) -> education (E). I am trying to predict next location (i.e. which will be more probable) and understand whether it will be food (F) -> education (E) -> home (H) or food (F) -> education (E) -> transport (T).

Bayesian formula looks as follows:

For any two events, A and B, p(B|A) = ( p(A|B) x p(B) ) / p(A)
I know independent probabilities of the next possible location :

P(H) = 0.2 (20% of all my locations are H)

P(T) = 0.15 (15% of all my locations are T)

P(F) = 0.10 (10% of all my locations are F)

P(E) = 0.22 (22% of all my locations are E)

In total I have 7 points and they give 1 in total. Also, I know that

P(FE) = 0.3 (chance that person will select F -> E path)

P(EH) = 0.12 (chance that person will select E -> H path)

P(ET) = 0.18 (chance that person will select E -> T path)

P(FET) = 0.4 (chance that person will select F -> E -> T path)

P(FEH) = 0.29 (chance that person will select F -> E -> H path)

And next I have to apply Bayesian formula two times (for F -> E -> T and F -> E -> H paths) and pick one with highest probability.

P(H|FE) = P(FE|H)∗P(H)/P(FE)=0.29∗0.20.3=0.19P(FE|H)∗P(H)/P(FE)=0.29∗0.2/0.3=0.19.

But I do not think that I am applying it correctly. Why we are not taking E -> H probability into account? I mean we should take into account the fact that only in 12% cases after E person selects H! (assuming we know nothing about what was before E in this case).

Do I understand everything correctly or not? Should I take P(EH) into account? If yes, how should I modify the formula?