How can I shift the average probability keeping constraint (0.0:1.0)? I have a large datasets of values that range from 0 to n. I am interpreting the values as probabilities for a later pseudo-random selection process. To make the values serve as probabilities, I normalize the entire dataset to the range (0.0:1.0) by dividing every number by n. Values are essentially random, and could be like {0.0156, 0.259, 0.0844, 0.904, ...}
After this, the dataset mean is not what I need it to be. (The end user will be specifying the desired mean). I need to transform (or dilate) all values so that the mean of the transformed dataset equals the desired mean, but the range constraint is unchanged. How can I do this?
Note, my question here is similar to How to simulate data that satisfy specific constraints such as having specific mean and standard deviation?, but the answers to that question do not constrain the range.
Edit
I have come up with a brute force iterative guessing approach to get the transformed mean to be within a tolerance of the target mean, but it will be slow. So now my question really is: Is there a closed form solution to get this exact?
 A: If the only property of the initial dataset that needs to be preserved is the rank order, then a variety of transformations are possible. Here's the simplest one I can think of:
Let $m$ be the mean specified by the user, and $x$ be the initial data ($n$ points). For $i=1,...,n$, define the new values as
$$ x_i' = 2m(i-0.5)/n $$
Map the $i$-th smallest $x$ to $x_i'$. Done: the new mean is
$$\sum_{i=1}^n (2m(i-0.5)/n)/n = 2m/n^2 \sum_{i=1}^n (i-0.5)= m$$
In fact, this is a special case of inverse rank transform, which allows you to map values between a pair of distributions. I just chose discrete uniform between $[0;2m]$ as the target, but you can choose any other distribution bound to $[0;1]$ and parametrized by mean.
More generally, this latter requirement - controlling the distribution by mean - generally makes little sense for bounded distributions, because you can't shift them left and right easily, and hence might end up with undesired effects such as the $<2m$ truncation above. It might be more natural to use another one, such as the beta distribution, and have the user control its parameters rather than the mean.
