Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 5614de0c authored by ulrich_y's avatar ulrich_y
Browse files

31.2 xi in #17: error band estimator

parent 3e7b1c3f
No related branches found
No related tags found
No related merge requests found
from scipy import optimize
import scipy.stats
import numpy as np
......@@ -18,3 +19,25 @@ def myfit(data, n):
covar = out[1]
return coeff, covar
def get_val(xs, coeff):
return [
sum(np.log(x)**np.arange(0,len(coeff)) * coeff)
for x in xs
]
def get_errorbands(x, coeff, covar, cf=0.9):
if type(x) == np.ndarray:
return np.array([
get_errorbands(i, coeff, covar, cf) for i in x
])
else:
tval = scipy.stats.t.ppf((cf+1)/2, len(coeff))
xvec = np.log(x)**np.arange(0,len(coeff))
delta = tval*np.sqrt(np.matmul(np.matmul(xvec, covar), xvec))
centre = sum(xvec * coeff)
return np.array([x, centre, centre+delta, centre-delta])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment