[Numpy-discussion] special function xlogy with 0log0=0

josef.pktd at gmail.com josef.pktd at gmail.com
Fri Jan 14 22:31:38 EST 2011

I'm trying to fix again a case with x*log(y) which was a converted
log(0**0), where x and y should broadcast.

Is it possible to get a special function for this. It shows up very
often, and any cheap fix, e.g.

term = x*np.log(y)
term[(x==0)*(y==0)] = 0

raises a warning (which I now also see)

 x*log(y+1e-300)  would be easier, but I don't know whether there are
no cases where numerical precision deteriorates.

In another version, Skipper clipped y

What's the best way?


More information about the NumPy-Discussion mailing list