Yet another power-law generator


Brownian motion trajectory, skewed slightly toward decrease. How long does it take to reach zero, how high does it go?

constant = 0.4   # if > 0.5 tends not to halt.

n = 1
length = 1
maximum = 1
while n:
    if random.random() < constant:
        n += 1
        value += 1
        n -= 1
    length += 1
    maximum = max(maximum,n) 

Both length and maximum appear to follow power law distributions, power dependant on constant.

This is nice because:

So what I am thinking is: look at sentence length and paragraph length in autistic vs normal writing. This data should be easier to get hold of. [though note that if the process contains multiple events occurring in parallel, such as an activation pattern in a randomly-connected network, the duration may not equal the number of iterations]

... a slight extension: the constant could be a function of n, mostly constant but smaller for n close to zero, and with some sort of saturation effect for large n. ... this also suggests a way to model learned helplessness, and ways to go about curing it.