Implements the formula for Bayesian curve fitting