It looks like you mixed up the probability of a particle decaying on a certain step, and the probability of a particle decaying by a given step. The probability of a particle decaying on any given step is the same, regardless of which step it is, while the probability that a particle has decayed by a given step is monotonically increasing. Instead of gradually increasing probdecay
, set it once, when you initialize the substance
:
def __init__(self, halflife):
self.probdecay = 1 - 0.5 ** (1.0 / halflife)
...