Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem calling np.random.multinomial from notebook

According to np.random.multinomial? this is what I should expect

np.random.multinomial(20, [1/6.]*6, size=2)
array([[3, 4, 3, 3, 4, 3],
       [2, 4, 3, 4, 0, 7]])

However when I type the same thing in notebook I get an error. The same command works fine in my system python. In sage notebook it works when I drop the argument size=2. This seems to be problem with sage notebook. Any suggestions?

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "", line 10, in <module>
    exec compile(u'open("","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("aW1wb3J0IG51bXB5IGFzIG5wCm5wLnJhbmRvbS5tdWx0aW5vbWlhbCgxMDAsIFsxLzIuMF0qMixzaXplPTMp"),globals())+"\\n"); execfile(os.path.abspath(""))
  File "", line 1, in <module>

  File "/tmp/tmpARgtW7/", line 4, in <module>
    exec compile(u'np.random.multinomial(_sage_const_100 , [_sage_const_1 /_sage_const_2p0 ]*_sage_const_2 ,size=_sage_const_3 )
  File "", line 1, in <module>

  File "mtrand.pyx", line 4050, in mtrand.RandomState.multinomial (numpy/random/mtrand/mtrand.c:17809)
  File "element.pyx", line 1305, in sage.structure.element.RingElement.__add__ (sage/structure/element.c:11569)
  File "coerce.pyx", line 797, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:7467)
TypeError: unsupported operand parent(s) for '+': 'Integer Ring' and '<type 'tuple'>'