The algebra and machine representation of statistical models