![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.python archiveRe: Generate a sequence of random numbers that sum up to 1?
From: Paul Rubin <//phr.cx@NOSPAM.invalid>
Date: Sun Apr 30 2006 - 01:36:57 CEST
Anthony Liu <antonyliu2002@yahoo.com> writes:
OK, this sounds like you actually want to divide the unit interval up
n = 10 # number of pieces desired
# Take the unit interval [0,1] and sprinkle in n-1 random points
# now find the size of each sub-interval and make a list
print sum(r) # should be 1.0 within rounding error
|