function [a,lin_series] = lin_regress(seriesX,seriesY);
% function [a,lin_series] = lin_regress(seriesX,seriesY);
%    Linear regression using least squares
% Author: Klaus Reiner Schenk-Hoppé (klaus@iew.unizh.ch)
% Last update: August 15, 2000

[m,n] = size(seriesX);
if n>m,
seriesX = transpose(seriesX);
end;

[m,n] = size(seriesY);
if n>m,
seriesY = transpose(seriesY);
end;

X = [ones(size(seriesX)) seriesX];

a = X\seriesY;

lin_series = transpose(X*a);
