Curve fitting with an invertible function

687 Views Asked by At

I have some data that need to be transformed as shown in the picture given some function.

example of input data and desired result

The function in question can take whatever form but with the following requirements:

  • It needs to be able to fit the data shown (i.e f(orange data) = blue data as much as possible)
  • It needs to be invertible
  • I need to be able to adjust its parameters so that in certain conditions it becomes identity

I've played around with various functions and although I can find various options that give a perfect fit, either I can't invert them or I can't figure out how to adjust the parameters to get an identity.

To give a more concrete example, let's say that a function of the form f(x) = ax + b could work (it doesn't). In this case the inverse function would be finv(x) = (x-b)/a. Now we could imagine a weight that is provided as an external parameter which goes between 0-1, in which case I could adjust parameters a and be so that

  • a'= w*a - (1-w) -> so that when the weight is at 1 we get the desired fitting behavior, when the weight is at 0 we get 1
  • b' = w*b -> so that b becomes 0 when the weight is 0 The above would give me f(x) = x when the weight is at 0 and ax+b when the weight is at 1.

What function could fulfil all 3 criteria given the form of the data I have?

Any ideas would be extremely welcome, I've been looking at this for days and I'm getting nowhere.

Thanks!

Edit to add some examples that give me a good fit: f(x) = ax/(b-x)^c

  • good fit, I can get it to become identity, but I don't see how to invert f(x) = (ax/(b-x))^c
  • good fit, invertible but can't get it to become identity

Throwing more parameters at it: f(x) = (ax^b)/(c-x^d)

  • again good fit, identity if I set a=1, b=1, c=2, d=0 but can't see how to invert
3

There are 3 best solutions below

1
On BEST ANSWER

How to fit a function to the inverse of a non-invertible function ?

This seems firstly to be a contradiction. Of course this should be a contradiction if we were looking for the analytically exact inverse function. But the problem is a problem of fitting, thus not entirely accurate. We are not looking for the inverse function itself, but for a function as close as possible to the inverse function.

A numerical example is shown below, in order to facilitate understanding.

FIRST PART : Fitting a function f(x) to the given data (x,y).

Deliberately a non-invertible function is chosen for the example.

enter image description here

SECOND PART : Fitting a function g(y) to the inverted data (y,x).

Deliberately a non-invertible function is chosen for the example. Deliberately again the function g which involves logarithms is not on the same kind than f which involves powers. We could have chosen both functions on the same kind if we like. The choice of the functions is entirely open insofar the two independent fittings can be correctly carried out.

enter image description here CHECKING :

Now we have two explicit functions f(x) and g(y) which are approximately the inverse one to the other.

We can check the discrepancy in comparing g(f(x)) to x and in comparing f(g(y)) to y :

enter image description here

0
On

Thaking account of your comment, you have to chose only analytically invertible functions. So your choice is very limited : polynomials of degree lower than five and a few other elementary functions without combination between them. I doubt that with a so limited choice an acceptable fitting to data be possible in general.

May I suggest another approach ?

First, fit to data any convenient function possibly not invertible, say $y=f(x)$ .

Second, fit to "inverted data" any other convenient function possibly not invertible, say $x=g(y)$. "Inverted data" means $(x,y)$ replaced by $(y,x)$.

So, you have a couple of functions which can be used the same way than if you have $f$ and $f^{-1}$. You can compute $g\big(f(x)\big)$ and compare to $x$ in order to evaluate the deviation. Or you can compute $f\big(g(y)\big)$ and compare to $y$.

0
On

The subject of your question is so wide and under-defined that I may provide only some general considerations and hints.

a) Since you are considering invertible functions, then you shall treat both coordinates "equivalently", meaning that you shall use Total regression, and in particular Deming regression.

b) To cope with invertibility requirement, you can probably use geometric regression, i.e. to fit curves implicitly defined as $f(x,y)=c$, since in that case inversion would just be $f(y,x)=c$.
You can for instance start and consider the conics.

c) You will always have two translation parameters, two scale parameters ad one rotation parameter, besides that defining ellipse/ parabola/ hyperbola.