0
$\begingroup$

I'm trying to come up with the correct algorithm for a setting on a meter in my app.

Basically, I have a value (lets call it 'x') returned from a source which can be in the range of 0 to 30.

As x goes from 30 to 0, I need y (the output of the algorithm) to go from 0 to 1.0. Basically, as x gets smaller, y needs to get larger but the rates of each are not proportional.

  • 0
    There are infinitely many solutions to your problem. For instance, the dependence might be quadratic, cubic, general polynomial, or exponential. Take your pick!2012-06-24
  • 0
    Is there some underlying physical connection between the meter reading and what it is reading? That might suggest an appropriate model?2012-06-24

1 Answers 1

1

There are many possible answers: $$y = 1 - \left(\frac{x}{30}\right)^k$$ or $$y = \left(\frac{30- x}{30}\right)^k$$ for some positive value of $k$ would each do what you ask: you might experiment. If $k=1$ then the relationship is linear.