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


Groups > comp.lang.python > #87104 > unrolled thread

Question about 'x' in pymc.invlogit(a+b*x)

Started byfl <rxjwg98@gmail.com>
First post2015-03-07 08:44 -0800
Last post2015-03-07 13:13 -0500
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Question about 'x' in pymc.invlogit(a+b*x) fl <rxjwg98@gmail.com> - 2015-03-07 08:44 -0800
    Re: Question about 'x' in pymc.invlogit(a+b*x) Terry Reedy <tjreedy@udel.edu> - 2015-03-07 13:13 -0500

#87104 — Question about 'x' in pymc.invlogit(a+b*x)

Fromfl <rxjwg98@gmail.com>
Date2015-03-07 08:44 -0800
SubjectQuestion about 'x' in pymc.invlogit(a+b*x)
Message-ID<c17c3949-32dc-4f02-850d-7534abbf9897@googlegroups.com>
Hi,

I once learnt Python for a few weeks. Now, I try to using a Python package
pymc. It has the following example code:




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)




I don't understand the 'x' in pymc.invlogit(a+b*x). Could you help me on it?


Thanks.

[toc] | [next] | [standalone]


#87119

FromTerry Reedy <tjreedy@udel.edu>
Date2015-03-07 13:13 -0500
Message-ID<mailman.157.1425752060.21433.python-list@python.org>
In reply to#87104
On 3/7/2015 11:44 AM, fl wrote:
> Hi,
>
> I once learnt Python for a few weeks. Now, I try to using a Python package
> pymc. It has the following example code:
>
>
>
>
> import pymc
> import numpy as np
> n = 5*np.ones(4,dtype=int)
> x = np.array([-.86,-.3,-.05,.73])

x is defined here as a module ('global') name

> 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)

x is used here.  Names in functions can be resolved in the local, 
(nonlocal, when present, but not here), global, and builtin namespaces, 
in that order.  They are resolved when the function is called.

> d = pymc.Binomial('d', n=n, p=theta, value=np.array([0.,1.,3.,5.]),\
> observed=True)

> I don't understand the 'x' in pymc.invlogit(a+b*x). Could you help me on it?

See comments, and contemplate this simplified example

 >>> def f(a): return a+b

 >>> b = 3
 >>> f(4)
7

-- 
Terry Jan Reedy

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web