[Numpy-discussion] Strange exp

Angelo Secchi secchi at sssup.it
Thu Aug 31 13:13:29 CDT 2006


Hi,
I have the following script 

import fileinput
import string
from math import *
from scipy import *
from rpy import *
import Numeric
import shelve
import sys

def dpolya1(n,N,b,a):
    a=float(a)
    b=float(b)
    L=784
    probs=((special.gammaln(N+1)+special.gammaln(L*(a/b))+special.gammaln((a/b)+n)+special.gammaln((a/b)*(L-1)+N-n))-(special.gammaln(L*(a/b)+N)+special.gammaln(a/b)+special.gammaln(n+1)+special.gammaln(N-n+1)+special.gammaln(L*(a/b)-(a/b))))#)
    return probs

and I observe the following "strange" (for me of course) behaviour

>>> dpolya1(1,2,0.5,0.4)
-5.9741312822170585
>>> type(dpolya1(1,2,0.5,0.4))
<type 'float64scalar'>
>>> exp(dpolya1(1,2,0.5,0.4))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'numpy.ndarray' object has no attribute 'exp'

I do not understand what's wrong. Any help?
Thanks
Angelo





More information about the Numpy-discussion mailing list