Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

As already pointed out by commenters, there are infinitely many such tuples. One way to generate them is:

def R31S1():
    A=[random() for u in range(31)]
    S=sum(A)
    return tuple([u/S for u in A])

Let's check:

sage: T=R31S1()
sage: type(T)
<class 'tuple'>
sage: len(T)
31
sage: sum(T)
1.0
sage: all([u>=0 and u<1 for u in T])
True
sage: T
(0.006089037356475367,
 0.02653861505103852,
 0.048525911647988376,
 0.030844994609170905,
 0.02700793870208519,
 0.07872299394844966,
 0.015087636977883111,
 0.06309180347147934,
 0.05423637336235927,
 0.052700158885111356,
 0.06602701660767711,
 0.0363743838933233,
 0.013134222937337785,
 0.04594966379579753,
 0.025102035013684295,
 0.04519431764115383,
 0.002292718973017283,
 0.012639236364503856,
 0.030852444551295627,
 0.07184775173604117,
 0.04969543126517173,
 0.03573006205560776,
 0.01675001424706971,
 0.0061099530976978155,
 0.04987299807905701,
 0.015149928406498115,
 0.0027994609852037985,
 0.013127271433974403,
 0.0011150285848061565,
 0.05054156008030657,
 0.00684903623873419)

All of this is basic Python, nothing Sage-specific...

HTH,