help how to sort a list in order of 'n' in python without using inbuilt functions??

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat May 25 23:38:12 EDT 2013


On Sun, 26 May 2013 03:23:44 +1000, Chris Angelico wrote:

> Does adding 1 to a random
> number make it less random? It adds determinism to the number; can a
> number be more deterministic while still no less random?
> 
> Ah! I know. The answer comes from common sense:
[snip spurious answer]

I know you're being funny, but in fact adding a constant to a random 
variable still leaves it equally random. Adding, multiplying, dividing or 
subtracting a constant from a random variable X just shifts the possible 
values X can take, it doesn't change the shape of the distribution. 
However, adding two random variables X and Y does change the 
distribution. In fact, a very cheap way of simulating an almost normally 
distributed random variable is to add up a whole lot of uniformly 
distributed random variables. Adding up 12 calls to random.random(), and 
subtracting 6, gives you a close approximation to a Gaussian random 
variable with mean 0 and standard deviation 1.



-- 
Steven



More information about the Python-list mailing list