Hi list,
I have found np.bincount() not to behave as expected when provided with
data from np.random.beta.
It works fine with lists, but not the type returned by np.random.beta...
there seems to be a block on casting too. When it does give output on
np.array it just reports the number of items, like len()
??
x = np.array([1,1,1,1,2,2,4,4,5,6,6,6])
print np.bincount(x)
prior = np.random.beta(2,7,1000)
a = prior.tolist()
print type(a)
print np.bincount(a)
b = [ round(i,2) for i in a ]
print b; print type(b)
print np.bincount(b)
#c = np.array(a)
#print np.bincount(c); print type(c)
i know its easily solved but bincount is probably faster than making a
pass over the probabilities and hashing them as strings etc
have got a class that subclasses dict and accepts np.random.beta as
'seq':
...
for prob in seq:
self.bincount( prob )
def bincount( self, pr, increment=1 ):
strPr = str(round(pr,self.dp))
self[strPr] = increment + self.get( strPr, 0 )
would prefer the one-liner:
self.bincount = np.bincount(seq)
any ideas?
thanks.
Michael Nandris
(btw apologies for the cross posting)
signature.asc
Description: This is a digitally signed message part
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion