Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
    
There are infinitely many solutions to your problem. For instance, the dependence might be quadratic, cubic, general polynomial, or exponential. Take your pick! –  dtldarek Jun 24 '12 at 23:19
    
Is there some underlying physical connection between the meter reading and what it is reading? That might suggest an appropriate model? –  copper.hat Jun 24 '12 at 23:37

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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