Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100445

Question about figure plot

Newsgroups comp.lang.python
Date 2015-12-14 18:43 -0800
Message-ID <ba4b4615-2739-49b3-9bb3-eafc527ddebc@googlegroups.com> (permalink)
Subject Question about figure plot
From Robert <rxjwg98@gmail.com>

Show all headers | View raw


Hi,

When I run the following code, there is no figure shown in the end.


//////////
import pymc
import numpy as np

n = 5*np.ones(4,dtype=int)
x = np.array([-.86,-.3,-.05,.73])

alpha = pymc.Normal('alpha',mu=0,tau=.01)
beta = pymc.Normal('beta',mu=0,tau=.01)

@pymc.deterministic
def theta(a=alpha, b=beta):
    """theta = logit^{-1}(a+b)"""
    return pymc.invlogit(a+b*x)
    
d = pymc.Binomial('d', n=n, p=theta, value=np.array([0.,1.,3.,5.]),\
                    observed=True)
....
import pymc
import mymodel

S = pymc.MCMC(mymodel, db='pickle')
S.sample(iter=10000, burn=5000, thin=2)
pymc.Matplot.plot(S)



I find that the figures are shown after these two lines by myself:
*************
import matplotlib.pyplot as plt
plt.show()

I have searched around and have not found some explanation about it.
The plot function here is different from Matlab's. Is there better ways than
my last two lines? (I am not confident whether my last two lines is the 
only choice.

Thanks,

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Question about figure plot Robert <rxjwg98@gmail.com> - 2015-12-14 18:43 -0800
  Re: Question about figure plot Robert Kern <robert.kern@gmail.com> - 2015-12-15 15:22 +0000

csiph-web