tags:

views:

149

answers:

2

I guess this is a math question and not a programming question, but what is a good way to create a formula that has diminishing returns?

Here are some example points on how I want the curve to look like.

f(1) = 1
f(1.5)= .98
f(2) = .95
f(2.5) = .9
f(3) = .8
f(4) = .7
f(5) = .6
f(10) = .5
f(20) = .25 

Notice that as the input gets higher, the percentage decreases rapidly. Is there any way to model a function that has a very smooth and accurate curve that says this?

Another way to say it is by using a real example. You know in Diablo II they have Magic Find? There are diminishing returns for magic find. If you get 100%, the real magic find is still 100%. But the more get, your actual magic find goes down. So much that say if you had 1200, your real magic find is probably 450%. So they have a function like:

actualMagicFind(magicFind) = // some way to reduced magic find
+9  A: 

f(x) = f(0)e-rx


Where r is the rate of compounded diminishing return

This is just exponential decay

Pierreten
Two questions, what is e?and is that e to the power of -r?
egervari
e is Euler's number; and everything after the ^ is exponetiated
Pierreten
Robert, how'd you do the LaTex formatting?
Pierreten
<sup>-rx</sup> (superscript tag)
Robert Harvey
Ah, didn't know there was markup for that; thanks
Pierreten
I'm not sure how to translate this. Let's take the magic find example I said above. Here are some examples: realMF(0) = 0, realMf(100)=100, realMf(200)=180, realMf(300)=250, realMf(600)=350, realMf(1200)=450. In this case, what is x? I looked on wikipedia and it's time, but I don't know the target time.
egervari
@egervari: if you want a curve "flat" around zero, use the Gaussian curve f(x)~e^(-x²/a²). f(x)~xe^(-rx) will produce behavior like in your comment, try realMF(x)=100x*e^(-x/1000)
Anton Tykhyy
@egervari: If you want a math equation that satisfies those points, you need to employ [curve fitting.](http://en.wikipedia.org/wiki/Curve_fitting)
Robert Harvey
x is just the independent variable; it can be time, distance, accumulated magic etc. Based on the points on your curve defined in the question; you should be able to find r. You already know that f(0) = 1; so that simplifies the function where you are only dealing with f(x) = e^-kx . The second point plugged in will yield .98 = e^-(k*1.5) . Solve this for k by taking the naturallog of both sides.
Pierreten
Thanks for all the advice. I eventually got to what I wanted with a combination of all the help here. LOL. I had many formulas in a game that are similar, so I would imagine each one is going to be different. One of the formulas went like this, where ratio was x in the my first examples: math.pow(math.E, -ratio / 20) * speed
egervari
Your `math.pow(math.E, stuff)` can be replaced by `math.exp(stuff)` in Java. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Math.html#exp(double)
dreeves
A: 

Any inverse exponential function, such as f(x) = 1/(x2). Modify the exponent to adjust the steepness of the curve.

Barry Brown