adjust mean of signal using exponential
You need to do it numerically, as a related toy problem $2^a + 3^a = 4$ appears to have no symbolic solution. Bisection method (binary search) is probably the easiest solver to implement:

minexponent = 0;
maxexponent = 2;
targetsum = 10;
precision = 32;
loop precision times {
  exponent = (minexponent + maxexponent)*0.5;
  if (sum(s.^exponent) &lt; targetsum) {
    maxexponent = exponent;
  } else {
    minexponent = exponent;
  }
}
return exponent;


The smallest possible exponent value is 0 for your problem. If you are unsure about the largest possible exponent value, you can test the easy-to-check exponents 1, 2, 4, 8, 16 etc. (as many as needed before the sum goes below the target) before the above code, exponentiating into an auxiliary array by multiplying each element by itself.

Note that if all of the elements are zero, or if all of the elements are one, then you cannot get any other mean than that by exponentiation.



The plot below shows 1000 runs of the algorithm, and the value of exponent at each iteration.