File: doc_confidence1.py

package info (click to toggle)
lmfit-py 0.8.0%2Bdfsg.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,776 kB
  • ctags: 1,203
  • sloc: python: 7,041; makefile: 102; sh: 43
file content (24 lines) | stat: -rw-r--r-- 398 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import lmfit
import numpy as np

x = np.linspace(0.3,10,100)
np.random.seed(0)

y = 1/(0.1*x)+2+0.1*np.random.randn(x.size)

p = lmfit.Parameters()
p.add_many(('a', 0.1), ('b', 1))

def residual(p):
   a = p['a'].value
   b = p['b'].value

   return 1/(a*x)+b-y

mi = lmfit.minimize(residual, p)
lmfit.printfuncs.report_fit(mi.params)

ci = lmfit.conf_interval(mi)
lmfit.printfuncs.report_ci(ci)