File: quadfit.py

package info (click to toggle)
python-bumps 1.0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,200 kB
  • sloc: python: 24,517; xml: 493; ansic: 373; makefile: 211; javascript: 99; sh: 94
file content (25 lines) | stat: -rwxr-xr-x 489 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python

from pylab import *
from dream import *

x = linspace(-4.0, 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)