Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One way to get "clumpy" numbers would be to use a normal distribution.</p> <p>You start the random list with your "initial" random value, then you generate a random number with the mean of the previous random value and a constant variance, and repeat as necessary. The overall variance of your entire list of random numbers should be approximately constant, but the "running average" of your numbers will drift randomly with no particular bias.</p> <pre><code>&gt;&gt;&gt; r = [1] &gt;&gt;&gt; for x in range(20): r.append(random.normalvariate(r[-1], 1)) &gt;&gt;&gt; r [1, 0.84583267252801408, 0.18585962715584259, 0.063850022580489857, 1.2892164299497422, 0.019381814281494991, 0.16043424295472472, 0.78446377124854461, 0.064401889591144235, 0.91845494342245126, 0.20196939102054179, -1.6521524237203531, -1.5373703928440983, -2.1442902977248215, 0.27655425357702956, 0.44417440706703393, 1.3128647361934616, 2.7402744740729705, 5.1420432435119352, 5.9326297626477125, 5.1547981880261782] </code></pre> <p>I know it's hard to tell by looking at the numbers, but you can <em>sort of</em> see that the numbers clump together a little bit - the 5.X's at the end, and the 0.X's on the second row.</p> <p>If you need only integers, you can just use a very large mean and variance, and truncate/divide to obtain integer output. Normal distributions by definition are a continuous distribution, meaning all real numbers are potential output - it is not restricted to integers.</p> <p>Here's a quick scatter plot in Excel of 200 numbers generated this way (starting at 0, constant variance of 1):</p> <p><a href="http://img178.imageshack.us/img178/8677/48855312.png" rel="nofollow noreferrer">scatter data http://img178.imageshack.us/img178/8677/48855312.png</a></p> <p><hr> Ah, I just read that you want non-repeating numbers. No guarantee of that in a normal distribution, so you might have to take into account some of the other approaches others have mentioned.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload