From 266d15cbc2dcc897702e77a8f5d6cbc30c15fad7 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 10 Apr 2012 22:44:12 +0200 Subject: Add octave script to print plots of products --- display_data.m | 29 +++++++++++++++++++++++++++++ split.sh | 8 ++++++++ 2 files changed, 37 insertions(+) create mode 100644 display_data.m create mode 100755 split.sh diff --git a/display_data.m b/display_data.m new file mode 100644 index 0000000..4affa96 --- /dev/null +++ b/display_data.m @@ -0,0 +1,29 @@ +for i = [30 45] + p = dlmread(sprintf("products/p%03d", i), " "); + + day = p(:,1); + quantity = p(:,4); + + middle = repmat(mean(p(:,4)), 42, 1); + middle_20 = repmat(mean(p(1:20, 4)), 42, 1); + + [m, n] = regress(day, quantity); + f = @(x) m .* x + n; + + [m, n] = regress(day(1:20), quantity(1:20)); + g = @(x) m .* x + n; + + figure + plot(day, p(:,4), "-;quantity;", + day, middle, "-;Mittelwert;", + day, middle_20, "-;Mittelwert 1-20;", + day, f(day), "-;Regression 1-42;", + day, g(day), "-;Regression 1-20;") + +endfor + +function [m, n] = regress(x, y) + mn = [ x ones(length(x), 1) ] \ y; + m = mn(1); + n = mn(2); +endfunction diff --git a/split.sh b/split.sh new file mode 100755 index 0000000..ee9458d --- /dev/null +++ b/split.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +sed 's/|/ /g' train.txt > train.csv + +for i in {1..570} +do + grep "^[0-9]* $i " train.csv > products/p$(printf "%03d" $i) +done -- cgit