1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
function pred = regress_pred(price, quantity, degree, prefunc)
days = size(price, 1) - size(quantity, 1);
product_count = size(price, 2);
test_count = size(quantity, 1);
test_set = 1:test_count;
pred_set = test_count+1:size(price, 1);
pred = zeros(days, product_count);
for i = 1:product_count
mn = regress(prefunc(price(test_set, i)), quantity(test_set, i), degree);
pred(:, i) = polyval(mn, prefunc(price(pred_set, i)));
end
pred = max(pred, 0);
endfunction
|