view 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
line wrap: on
line source

import numpy as np

def error(function, x, y):
    """
    computes true value and error and returns
    them both as a 2-tuple
    """

    yhat = np.array([function(*val) for val in x])
    error = yhat - np.array(y)

    return (yhat, error)