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

  • 4
    $\begingroup$ 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? $\endgroup$
    – Alex J
    Sep 27, 2023 at 6:23
  • $\begingroup$ 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. $\endgroup$ Sep 27, 2023 at 7:04
  • $\begingroup$ 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? $\endgroup$ Sep 27, 2023 at 7:34
  • $\begingroup$ 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. $\endgroup$
    – Peter Flom
    Sep 27, 2023 at 10:41
  • $\begingroup$ 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. $\endgroup$ Sep 28, 2023 at 15:42

1 Answer 1


It can't be done.

The mean value of data restricted to the range [-1, 1] of course must be in [-1, 1]. If your original data has mean outside of [-1, 1], it is impossible to restrict the range and keep the same mean. It simply not possible to map any arbitrary distribution to the range [-1, 1] and keep the same mean, as there are infinitely many distributions which do not have mean in [-1, 1] to begin with.

Consider a typical die with faces numbered 1-6, which has a mean value of 3.5 when rolled. It is not possible to write different numbers between -1 and 1 on the faces of the die and have the mean still come out at 3.5.

  • $\begingroup$ Let me re-phrase... can I shift a distribution or dataset with arbitrary range and mean, to a range of [-1,1] with a mean I specify within that range, say mean = 0? $\endgroup$ Sep 29, 2023 at 16:37
  • $\begingroup$ 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].$ $\endgroup$
    – whuber
    Sep 29, 2023 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.