Recursive method seems to work but the numbers need fiddling to get the
best results out.  Also added functions for regression into the
functions module.