Add Python files for bitrate accuracy experiment.

The first method uses least squares linear regression to compute the
singular scale factor when we don't take motion vectors into account.

The second method uses the pseudoinverse matrix method to compute the two scale factors
(for the frame bitrate and mv bitrate) when we take motion vectors into
account.

BUG=aomedia:3045

Change-Id: Ia6f0546b6883878d724912dc85e0f2b21dc80036
diff --git a/tools/gop_bitrate/python/bitrate_accuracy.py b/tools/gop_bitrate/python/bitrate_accuracy.py
new file mode 100644
index 0000000..565794f
--- /dev/null
+++ b/tools/gop_bitrate/python/bitrate_accuracy.py
@@ -0,0 +1,40 @@
+import numpy as np
+
+# Uses least squares regression to find the solution
+# when there is one unknown variable.
+def print_lstsq_solution(A, B):
+    A_inv = np.linalg.pinv(A)
+    x = np.matmul(A_inv, B)
+    print("least squares solution:", x[0][0])
+
+# Uses the pseudoinverse matrix to find the solution
+# when there are two unknown variables.
+def print_pinv_solution(A, mv, B):
+    new_A = np.concatenate((A, mv), axis=1)
+    new_A_inv = np.linalg.pinv(new_A)
+    new_x = np.matmul(new_A_inv, B)
+    print("pinv solution:", new_x[0][0], new_x[1][0])
+
+# Traverses the data and prints out one value for
+# each update type.
+def print_solutions(file_path):
+    data = np.genfromtxt(file_path, delimiter="\t")
+
+    prev_update = 0
+    split_list_indices = list()
+    for i, val in enumerate(data):
+        if prev_update != val[3]:
+            split_list_indices.append(i)
+            prev_update = val[3]
+
+    split = np.split(data, split_list_indices)
+
+    for array in split:
+        A, mv, B, update = np.hsplit(array, 4)
+        print("update type:", update[0][0])
+        print_lstsq_solution(A, B)
+        print_pinv_solution(A, mv, B)
+        print()
+
+if __name__ == "__main__":
+    print_solutions("data/lowres_64f_target150_data.txt")