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


Groups > comp.lang.python > #82442

Re: list comprehension return a list and sum over in loop

Newsgroups comp.lang.python
Date 2014-12-12 05:03 -0800
References (1 earlier) <mailman.16893.1418368651.18130.python-list@python.org> <d03ea4ee-a361-4901-b799-d7d1c5f85ee5@googlegroups.com> <mailman.16901.1418375626.18130.python-list@python.org> <a5c1fd3e-1724-4ade-9c64-27ab0ec8be37@googlegroups.com> <qota92ti0ks.fsf@ruuvi.it.helsinki.fi>
Message-ID <b3f70286-95fd-4daf-bae3-af7e6b78968c@googlegroups.com> (permalink)
Subject Re: list comprehension return a list and sum over in loop
From KK Sasa <genwei007@gmail.com>

Show all headers | View raw


Jussi Piitulainen於 2014年12月12日星期五UTC+8下午7時12分39秒寫道:
> KK Sasa writes:
> 
> > def p(x,t,point,z,obs):    
> >     d = x[0]
> >     tau = [0]+[x[1:point]] 
> >     a = x[point:len(x)]
> >     at = sum(i*j for i, j in zip(a, t))
> >     nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)]
> >     de = sum(nu, axis=0)
> >     probability = [nu[k]/de for k in xrange(point)]
> >     return probability[obs]
> 
> I must be blind, but this looks like computing a whole probability
> distribution and then throwing almost all of it away.
> 
> Can't this just return nu[obs]/de?
> 
> The expression for tau also seems weird to me. Isn't it equivalent to
> [0, x[1:point]], a two-element list with the second element a list?
> How can sum(tau[k]) work at all then, for any k > 1?

This is just a probability of binary response. Not continuous one. Tau is a parameter and just have two in this case.

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


Thread

list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-11 22:22 -0800
  Re: list comprehension return a list and sum over in loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-12-12 07:17 +0000
    Re: list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-12 00:30 -0800
      Re: list comprehension return a list and sum over in loop Christian Gollwitzer <auriocus@gmx.de> - 2014-12-12 10:09 +0100
      Re: list comprehension return a list and sum over in loop Peter Otten <__peter__@web.de> - 2014-12-12 10:13 +0100
        Re: list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-12 01:45 -0800
          Re: list comprehension return a list and sum over in loop Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-12-12 13:12 +0200
            Re: list comprehension return a list and sum over in loop Peter Otten <__peter__@web.de> - 2014-12-12 13:32 +0100
              Re: list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-12 05:09 -0800
                Re: list comprehension return a list and sum over in loop Peter Otten <__peter__@web.de> - 2014-12-12 17:08 +0100
                Re: list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-12 19:04 -0800
                Re: list comprehension return a list and sum over in loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-12-13 11:27 +0000
            Re: list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-12 05:03 -0800
  Re: list comprehension return a list and sum over in loop Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-12 20:46 +1100
  Re: list comprehension return a list and sum over in loop Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-12-12 16:47 +0000
  Re: list comprehension return a list and sum over in loop pecore@pascolo.net - 2014-12-13 13:38 +0100

csiph-web