# Find a function that fits data and has certain characteristics

I have some data.

data = [
(10000, 0),
(100000, 0.25),
(10000000, 0.5),
]


I want to find function(s) fitting this data. I have a possible starting point:

f(x) = Ax / (B + x) - C


Can I find A, B, C satisfying the data?

The function should be continuous. f(x) for x<=10000 does not matter but should be negligible or negative for x<=10000. The function should have an asymptotic maximum < 1.

-
What are you really trying to do, and why do you want a function that behaves in the way you have described? – J. M. May 12 '12 at 1:42
Create a progressive tax code without the ridiculous discrete brackets. – Skylar Saveland May 12 '12 at 1:45
But, mostly just to learn some math. – Skylar Saveland May 12 '12 at 1:56
Not of the form with your "starting point", but you can get one using logistic functions. – Arturo Magidin May 12 '12 at 2:25
What is ridiculous about discrete brackets? – Gerry Myerson May 12 '12 at 6:41

As you have the same number of free parameters as data points, you can write three simultaneous equations in three unknowns and solve, but that may not meet the end cases. The functional form you give goes to $A-C$ for large $x$ and to $-C$ for $x=0$. If you want it zero at $x=0$ you have to have $C=0$. Then you have one more data point than parameters. You could minimize the error over A and B and see if you like the result.

It is easy to change parameters in a function-your $A, B, C$. It is hard to change the form of a function.

-
You make a good point: The functional form you give goes to A−C for large x and to −C for x=0. If you want it zero at x=0 you have to have C=0 I edited now to read: f(x) for x<=10000 does not matter but should be negligible or negative for x<=10000 – Skylar Saveland May 12 '12 at 2:32
You can certainly maintain continuity and get zero for small $x$ by taking $g(x)=\max(0, f(x))$ for your $f(x)$ but maybe that feels like the bracket problem. Do you have Excel? It has goal seek-make a spreadsheet that has $A,B,C$ as input and calculates your $f(x)$. Then square the errors from your desired values and tell it to minimize. Then make a table for many values of $x$, plot it, and see if you like the result. You could also create more desired pairs-it will minimize just the same. – Ross Millikan May 12 '12 at 2:39

This function satisfies your 3 example data points, although I believe it falls short of your intention:

f(x) = logb2(logb10(x/1000))/4

Here's a function that is similar to the desired function:

f(x) = 1 - (1/log(x/1000)) for x>=10,000

f(x) = 0 for x < 10,000

This function has a limit <= 1 and produces:

• f(10,000) = 0
• f(100,000) = .5
• f(10,000,000) = .75

Not the same as the example data points, but this form may be useful as a starting point.

-
It does not satisfy the asymptotic maximum less than 1, however. – Ross Millikan May 12 '12 at 22:09