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.

enter image description here

I'm trying to create an idea fitness function using an inverse parabola but I'm struggling with the math.

Basically what I have is:

score = -1 * (actual-ideal)^2 + weight

Or 0 if the score is negative. This works great except that it's not flat enough, and it gives no score if the actual isn't close enough to the idea (at least not a positive value).

What I would ideally like is some kind of minimum score, so that f(0)=0, f(1)>0, etc. and anything above that in terms of x has some kind of value peaking at the ideal value.

Even better would be if I could have the score slowly decrease when the value goes past the ideal, but I'm ok with say 2*ideal being 0, so it's an inverse parabola. A more complex function would be awesome but right now I'm just looking for something simpler.

How would you adjust the equation above so that the score always starts at 0 and peaks out at the ideal?

share|improve this question
    
Unless you have a good reason to say what that curve looks like, why not use a piecewise linear function? Or, if this is acceptably "flatter", replace the power of 2 with a power of 4. –  Eric Tressler Aug 6 '13 at 3:36
    
Because as the scores get closer, I need to be able to better and better differentiate the differences which won't work with a linear function. Also each value closer to the ideal is actually much much harder to achieve. So for example, if you're running, the difference between running say the 100 meter dash in 20 seconds versus 23 seconds isn't that big a deal. But the difference between say running 9.3 seconds and 9.2 seconds is all the difference when you get to a professional level. That's what I'm trying to measure as I get closer and closer to the ideal. –  Stephane Grenier Aug 6 '13 at 3:44
add comment

1 Answer 1

So you want to map the difference between actual and ideal to a score, where $f(0)$ is the max?

$f(x) = -(x-c)(x+c)$

Where $x$ is actual minus ideal and $c$ is just how big the difference needs to be to give $0$.

If you want a function directly of the actual:

$g(x) = -((x-I)-c)((x-I)+c)$

Where $I$ is the ideal

Put $g(0) = 0$ and see that $c$ can be $I$ or $-I$ (clearly doesn't matter which).

$g(x) = -x(x-2I)$

Is this what you're looking for?

share|improve this answer
add comment

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.