Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; "subject:' ": 0.07; 'subject:Question': 0.07; 'weeks.': 0.07; 'builtin': 0.09; 'global,': 0.09; 'present,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'def': 0.12; 'jan': 0.12; 'called.': 0.16; 'learnt': 0.16; 'numpy': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'simplified': 0.16; 'alpha': 0.16; 'wrote:': 0.18; 'module': 0.19; 'resolved': 0.19; '>>>': 0.22; 'example': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'order.': 0.26; 'skip:v 30': 0.26; 'code:': 0.26; 'defined': 0.27; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'skip:p 30': 0.29; 'am,': 0.29; 'comments,': 0.31; 'could': 0.34; 'but': 0.35; 'hi,': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'name': 0.63; 'here': 0.66; '11:44': 0.84; 'contemplate': 0.84; 'local,': 0.84; 'received:fios.verizon.net': 0.84; 'subject:*': 0.91; 'subject:+': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Question about 'x' in pymc.invlogit(a+b*x) Date: Sat, 07 Mar 2015 13:13:59 -0500 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-98-114-97-173.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425752060 news.xs4all.nl 2914 [2001:888:2000:d::a6]:53217 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87119 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