list comprehension return a list and sum over in loop
KK Sasa
genwei007 at gmail.com
Fri Dec 12 08:03:07 EST 2014
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.
More information about the Python-list
mailing list