summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-05-14 08:17:06 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-05-14 08:18:42 +0200
commit1ddc4c5ae33404253b98409206834777274f6cd9 (patch)
tree280a2218643f53deb2e02380c95002ba2645e7eb
parent98ff15ec1b53da5ea74a1c02f023260d0d598c0c (diff)
downloaddmc-1ddc4c5ae33404253b98409206834777274f6cd9.tar.gz
dmc-1ddc4c5ae33404253b98409206834777274f6cd9.tar.bz2
dmc-1ddc4c5ae33404253b98409206834777274f6cd9.zip
Dont return negative quantities in regression
-rw-r--r--regress_frequency_removal.m1
-rw-r--r--regress_pred.m1
2 files changed, 2 insertions, 0 deletions
diff --git a/regress_frequency_removal.m b/regress_frequency_removal.m
index a60d93a..36fed96 100644
--- a/regress_frequency_removal.m
+++ b/regress_frequency_removal.m
@@ -12,4 +12,5 @@ function pred = regress_frequency_removal(price, quantity)
%pred = (pred .* (removed == 0)) + removed;
pred = pred + removed;
pred = real(ifft(pred));
+ pred = max(pred, 0);
endfunction
diff --git a/regress_pred.m b/regress_pred.m
index 8788bee..0bb5ca9 100644
--- a/regress_pred.m
+++ b/regress_pred.m
@@ -11,5 +11,6 @@ function pred = regress_pred(price, quantity, degree, prefunc)
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