Background: I am developing an app to make calculations for worldbuiding, following the instructions given by the YouTube channel Artifexian. In one of the videos, he mentions a formula to keep the eccentricities of the orbits in check. The video in question I'm now working on is this one.
If I want to keep an average of, say, 5, my numbers could be: 9, 1, 3, 7, 10, 0, 4, 6, 5. This were hand picked, but what if the average must be 0.085 like in the video? The app can set in advance how many planets the system will have, so I know what the average eccentricity should be, but how can I set random eccentricity values while keeping that average. Is there a math way to do it?
I'm posting this question here because I think it is more related to math than to worldbuiding or science.
Edit: the average eccentricity for 2 planets should be 0.254; for 3, 0.156; 4, 0.111; 6, 0.068; 7, 0.057 and for 8, 0.048.
The average of a set of numbers depends only on how many numbers there are, and on their sum. Thus, if you want ten numbers, with an average of $0.085$, you simply need to ensure that their sum is $10\times 0.085=0.85$.
In order to get that total, just pick the first nine choices without their sum going over $0.85$, and then make the tenth number equal to $0.85$ minus the first nine.
Another approach would be to start with all of the numbers the same – equal to your desired average – and then start modifying them in a way that preserves their sum, and therefore also preserves their average. For instance, subtract a small quantity from one of the eccentricities, and add the same quantity to another one. You can do this as many times as you like, until your numbers are sufficiently non-uniform.