Suppose I have a list of numbers $(y_1, y_2, y_3, \dots, y_N)$ with these properties:
$$ \sum_{i=1}^{N}y_i = 13\, 776\, 663, $$ $$ \bar{y} = \dfrac{1}{N} \sum_{i=1}^{N}y_i = 17\,135, $$ $$ s^2 = \dfrac{1}{N-1} \sum_{i=1}^{N}(y_i - \bar{y})^2 = 139\,147^2. $$
That list has these numbers:
- The lowest is $19$.
- The $5$th percentile is $336$
- The $25$th percentile is $800$
- The median is $1\,668$
- The $75$th percentile is $5\,050$
- The $95$th percentile is $30\,295$
- The highest is $2\,627\,319$
These percentiles give you some idea about the distribution of the numbers. I can construct a list that has that mean and standard deviation, it doesn't matter if any $y_i$ is less than zero or if it does not follow the described distribution. The problem I face is to construct a list with mean $\bar y$ and standard deviation $s$ subject to the condition that every $y_i$ has to be greater than zero (it doesn't have to follow that distribution and it doesn't have to have those numbers).
So I am looking for a way to do that. If anybody has any ideas about this, I'm happy to hear them!
The solution is probably not unique, and you would want to do it numerically. I would use the approach found in Datasaurus dataset. The first step is to find $N$. From the first two equations you get $N\approx804$. Since $N$ is not exactly an integer, the first indication that I have that these numbers are just an approximation. The last equation gives you $\bar{y^2}$. Now choose $y_1=19$ and $y_{408}=2627319$. You can now recalculate $\bar y$ and $\bar{y^2}$ without those values. Put $203$ values on the median and the other $203$ remaining at a value such that the average (or the sum) is your desired value. Obviously, $\bar{y^2}$ is going to be wrong. Move one value from the median down, somewhere in the lower 5th percentile. To get the same average, you must move at least one value from the higher dataset upward. Check if moving one value or moving two values higher will improve your $\bar{y^2}$. You need to repeat this procedure until all your conditions are met.