Variable order Bayesian network