Re: Generate a sequence of random numbers that sum up to 1?



fumanchu <fumanchu@xxxxxxxx> wrote:

I'm surprised noone has pursued a course of subtraction rather than
division. Say you want 10 numbers:

s = 1.0
n = []
for x in xrange(9):
... value = random.random() * s
... n.append(value)
... s -= value
...
n.append(s)
n
[0.7279111122901516, 0.082128708606867745, 0.0080516733577621798,
0.12122060245902817, 0.0034460458833209676, 0.0021046234724371184,
0.054109424914363845, 0.00035750970249204185, 0.00051175075536832372,
0.00015854855820800087]
sum(n)
1.0


Either:
1) Just because they're *ordered* doesn't mean they're not *random*,
or
2) You all now know why I'm not a mathematician. ;)

It seems to me that the only constraint on the randomness of my results
is the OP's constraint: that they sum to 1. I'd be fascinated to learn
if and why that wouldn't work.

n[0] is uniformly distributed between 0 and 1; n[1] is not -- not sure
how to characterize its distribution, but it's vastly skewed to favor
smaller values -- and further n[x] values for x>1 are progressively more
and more skewed similarly.

Such total disuniformity, where the very distribution of each value is
skewed by the preceding one, may still be "random" for some sufficiently
vague meaning of "random", but my intuition suggests it's unlikely to
prove satisfactory for the OP's purposes.


Alex
.



Relevant Pages

  • Re: Explanation of Maximum Entropy
    ... > best distribution pay at least a little attention to the data? ... MaxEnt isn't very useful for the coin toss example. ... non-trivial constraint derived from the data that would not determine ... parameters of a Beta prior, it would prescribe you _symmetric_ ...
    (sci.stat.math)
  • Re: Phoneme analysis. (Motherhood statements?) (Long!)
    ... Constraint on distribution of /r/: ... certain vowels precede. ... Not in syllable onset. ...
    (sci.lang)
  • Re: uniform distribution of P points on a (D) dimensions sphere
    ... be distributed "uniformly" in dimensions, ... constraint mentioned in your first paragraph should be equally "optimal", ... Given a solution to that problem, you can scale each vector by ... distribution of the resulting points is rotationally invariant. ...
    (sci.math)
  • Re: Fitting characters to a grid
    ... have to comply with the rules of the grid, so you will not have a truly ... random distibution on the second row - rather a constrained ... distribution. ... the degree of constraint will ...
    (microsoft.public.excel)