bayes.py modified