# Transform data domain and maintain mean

I have a dataset, $$y$$, that is on some arbitrary range. I would like to transform this data to be on the range [-1,1]. This is accomplished using a linear transformation, such as the one described here: scale a number between a range

However, I would also like to specify the mean of the re-scaled data, within the range [-1,1]. When transforming the re-scaled data to accomplish this desired mean, you lose the correct boundaries/range.

How can I shift an arbitrary dataset to an arbitrary range AND hit a target mean? For example, mean = 0 on range [-1,1] for any arbitrary dataset X

• You can't do both, except if your data is already the specified range. Maybe edit your question to say what you're trying to achieve with this? Sep 27, 2023 at 6:23
• Any linear transformation of data will transform the mean in the same way, and rescale the standard deviation, so the only such transformation that does not change the mean and the standard deviation is the identify "transformation". As Alex, I would recommend you tell us what substantive issue you are facing. Sep 27, 2023 at 7:04
• Ultimately I am trying to generate a Beta Distribution that I then scale to the desired range of [-1,1] for input into Jacobi Polynomials, but I also want to be able to control the mean and variance. I am aware, however, that I can control the mean/variance initially by adjusting the alpha/beta parameters. Perhaps I can achieve both by using the 4-parameter Beta distribution? Although, that just incorporates the linear transformation so we would face the same issue I assume? Sep 27, 2023 at 7:34
• Yes, it will have the same problem. I mean, to make it obvious, a distribution in the range of -1 to +1 will have a mean between those two numbers. Sep 27, 2023 at 10:41
• So there is really no way, even algorithmically, to map one distribution to another range while maintaining mean? We can forget about variance, I actually just need mean and range specified. Sep 28, 2023 at 15:42

• It depends on what you mean by "shift." The usual meaning is "add a constant," but in that case if the range of your distribution is longer than $2,$ there's no way a simple shift can stuff it into any interval of length $2$ like $[-1,1].$