http://www.perlmonks.org?node_id=562023


in reply to Calculating your basic $constant, $slope, and $error terms for a time series distribution

Maybe Statistics::Regression and rest of statistics modules can help you...