I have discrete signals whose values are between 0 and 1.

I wish to post-process such a signal such that the mean of its values equals 0.5, yet keeping maximum and minimum values 0/1 intact. Intuitively, I think an 'element-wise' exponential would be the right approach, yet I can't seem to come up with the method to determine the value of the appropriate exponential.

Fictive matlab example to illustrate:

>> s=[0.2 0.7 1 0.5 0.4 0.2 0 0.3];
>> mu=mean(s)
mu =  0.41250
>> s_adjusted=s.^0.69998;
>> mu_adjusted=mean(s_adjusted)
mu_adjusted =  0.50000

What is the best method to determine the 0.69998 exponential ?

  • $\begingroup$ This is not an exponential but a power law. $\endgroup$ – Yves Daoust Sep 21 '15 at 8:26
  • $\begingroup$ @YvesDaoust: This is a subtlety that I don’t master. Can you please elaborate? $\endgroup$ – Stevo Sep 21 '15 at 12:44
  • $\begingroup$ Subtle. You are performing an exponentiation of each of your samples $s$, with exponent or power $a$. It is defined as $s^a = \exp{a \log{s}}$ for $s>0$, a sort of exponential of a $\log{s}$, called a power-law. An "exponential" of your data could be thought to take a form like $\exp{a s}$. $\endgroup$ – Laurent Duval Sep 22 '15 at 17:31

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) < 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.

Plot of 1000 applications of the algorithm

| improve this answer | |
  • $\begingroup$ Thanks for your answer. It makes it evident that I indeed would need to go down a numerical root-finding approach. The bisection method is probably good-enough for my purpose and indeed simplest (vs other root finding methods I've just read about) $\endgroup$ – Stevo Sep 21 '15 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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