Hi ,
I have written a function which takes a long time to be run. How can I
make it faster?
def urn(number,k1,delta):
p = list(SetPartitions(number).list()) # set of all partitions
p1 = list(SetPartitions(number,k1).list())
p2 = list(SetPartitions(number,(k1+delta)).list())
l1 = len(p1)-1
l2 = len(p2)-1
trivial = p[0]
counter = int(0)
rounds = int(100)
for i in range(rounds):
sp1 = p[randint(0,l1)]
sp2 = p[randint(0,l2)]
if sage.combinat.set_partition.sup(sp1, sp2) == trivial:
counter = counter + 1
probability = counter/rounds
return probability
for i in range(-3,3):
n(urn(10,5,i))
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org