File: quadfit.py

package info (click to toggle)
python-bumps 0.7.11-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,264 kB
  • sloc: python: 22,226; ansic: 4,973; cpp: 4,849; xml: 493; makefile: 163; perl: 108; sh: 101
file content (23 lines) | stat: -rwxr-xr-x 518 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python

from pylab import *
from dream import *

x = linspace(-4., 4, 40)
fn = lambda p: polyval(p,x)
bounds=(-20,-20,-20),(40,40,40)
sigma = 1
data = fn((2,-1,3)) + randn(*x.shape)*sigma  # Fake data


n=len(bounds[0])
model = Simulation(f=fn, data=data, sigma=sigma, bounds=bounds)
sampler = Dream(model=model,
                population=randn(5*n,4,n),
                thinning=1,
                draws=20000,
                )

mc = sampler.sample()
figure(6); model.plot(mc.best()[0])
plot_all(mc)