annotate tvii/error.py @ 70:351fc97bb996

add error computation + test functions
author Jeff Hammel <k0scist@gmail.com>
date Sun, 17 Dec 2017 13:22:44 -0800
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 import numpy as np
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 def error(function, x, y):
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 """
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 computes true value and error and returns
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6 them both as a 2-tuple
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 """
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 yhat = np.array([function(*val) for val in x])
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 error = yhat - np.array(y)
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11
351fc97bb996 add error computation + test functions
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 return (yhat, error)