Esempio n. 1
0
import pylab as pl
import pymc as mc

import models
import graphics

# make model
vars = models.nonlinear()
#vars['beta'].value = [10, -9, 15]  # carefully choosen initial value, for demonstration purposes only

m = mc.MCMC(vars)
m.sample(iter=20000, burn=10000, thin=10)

# display results
pl.figure(figsize=(12,9))
graphics.plot_2005_data()
graphics.plot_nonlinear_model(m)

pl.savefig('../tex/ex2.png')
Esempio n. 2
0
# make and fit model twice
vars = models.nonlinear()
vars['gamma'].value = .95
vars['beta'].value = [
    10, -10, 15
]  # carefully choosen initial value, for demonstration purposes only
m1 = mc.MCMC(vars)
m1.sample(iter=20000, burn=10000, thin=10)

vars = models.nonlinear()
vars['gamma'].value = .95
vars['beta'].value = [8, -8, 10]  # as above
m2 = mc.MCMC(vars)
m2.sample(iter=20000, burn=10000, thin=10)

# display results
pl.figure(figsize=(12, 9))
graphics.plot_2005_data()
graphics.plot_nonlinear_model(m1, color='g', label='Replicate 1')
pl.axis([.8, .99, 1., 3.])

pl.savefig('../tex/ex3_a.png')

graphics.plot_nonlinear_model(m2, color='b', label='Replicate 2')
pl.axis([.8, .99, 1., 3.])

pl.savefig('../tex/ex3_b.png')

# explore model convergence
mc.Matplot.plot(m1, path='../tex/ex3')
Esempio n. 3
0
import pylab as pl
import pymc as mc

import models
import graphics

# make model
vars = models.nonlinear()
#vars['beta'].value = [10, -9, 15]  # carefully choosen initial value, for demonstration purposes only

m = mc.MCMC(vars)
m.sample(iter=20000, burn=10000, thin=10)

# display results
pl.figure(figsize=(12, 9))
graphics.plot_2005_data()
graphics.plot_nonlinear_model(m)

pl.savefig('../tex/ex2.png')
Esempio n. 4
0
import graphics

# make and fit model twice
vars = models.nonlinear()
vars['gamma'].value = .95
vars['beta'].value = [10, -10, 15]  # carefully choosen initial value, for demonstration purposes only
m1 = mc.MCMC(vars)
m1.sample(iter=20000, burn=10000, thin=10)

vars = models.nonlinear()
vars['gamma'].value = .95
vars['beta'].value = [8, -8, 10]  # as above
m2 = mc.MCMC(vars)
m2.sample(iter=20000, burn=10000, thin=10)

# display results
pl.figure(figsize=(12,9))
graphics.plot_2005_data()
graphics.plot_nonlinear_model(m1, color='g', label='Replicate 1')
pl.axis([.8, .99, 1., 3.])

pl.savefig('../tex/ex3_a.png')

graphics.plot_nonlinear_model(m2, color='b', label='Replicate 2')
pl.axis([.8, .99, 1., 3.])

pl.savefig('../tex/ex3_b.png')

# explore model convergence
mc.Matplot.plot(m1, path='../tex/ex3')