Bayes risk and optimization

Added support for bayes risk and added a risk function that can be
called directly by scipy.optimize.fmin_cg.  Also added Q to model,
probably should be put in abstract model but change not implemented yet.
Lineending hell.
Merged changes with HEAD.