[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: Python Random vs. Cython C Rand for Dice Rolls
From:       Jeremy Sanders <jeremy () jeremysanders ! net>
Date:       2015-06-08 7:43:33
Message-ID: ml3h1v$pjo$1 () ger ! gmane ! org
[Download RAW message or body]

C.D. Reimer wrote:

> Is there something in the Cython code that I need to change and/or find
> a better C random number generator?

This may not be helpful, but numpy is pretty helpful for this sort of thing:

import numpy
import numpy.random

a=numpy.random.randint(1,6,50000000)
b=numpy.random.randint(1,6,50000000)

numpy.bincount(a+b-1)

array([      0, 1999229, 4000369, 5999372, 7999232, 9998769, 8003430,
       5998538, 4001160, 1999901])

This takes a few seconds on my system.

Jeremy


-- 
https://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic