Python three random proportional intervals to generate random number algorithm

  1. Total number of intervals is Total=18
  2. the interval is divided into three parts: T1, T2, T3
  3. each interval has a minimum, maximum to range, as follows:

    T1 = [1gamma 18gamma 3gamma 18]
    T2 = [10gamma 18lemaget 16Compact 18]
    T3 = [1gamma 18gamma 5gamma 18]

    the code is as follows

def prorate(total):
    T1 = random.uniform((total*(1/18.00)),(total*(3/18.00)))
    T2 = random.uniform(((total-T1)*(10/18.00)),((total-T1)*(16/18.00)))
    T3 = random.uniform(((total-T1-T2)*(1/18.00)),((total-T1-T2)*(5/18.00)))
    return T1,T2,T3

the sum=T1+T2+T3 printed in this way has a big error with the initial value total.
is there any other way to realize the method of randomly proportionally dividing intervals, generating random numbers, and then fixing the sum value to total

?
Jun.28,2022

def prorate(total):
    p1 = random.uniform(1/18.0, 3/18.0)
    p3 = random.uniform(1/18.0, 5/18.0)
    p2 = 1-p1-p3
    return total*p1,total*p2,total*p3

the range of p1+p3 is in the range of 2 br, 18, 8 and 18
p2, and the range is 10, 18, 16, and 18

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bedae6-31b83.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bedae6-31b83.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?