A General Algorithm for Approximate Inference and its Application to Hybrid Bayes Nets