0

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
  • 2
    Welcome to the site !. Could you provide a dew examples of perfect fit ? May be (?), it could be possible to invert them. – Claude Leibovici Nov 18 '20 at 11:30
  • xartaetos: Sorry, for me your question is incomprehensible as it it presently written. @Claude Leibovici. Hi Claude ! You are lucky to understand what the OP means. Best regards. – JJacquelin Nov 18 '20 at 11:37
  • @Claude Leibovici I added a few examples of functions I tried that give a good fit, but I either don't see how to invert them or I can't figure out how to set their parameters to get identity. Thanks for looking! – xartaetos Nov 18 '20 at 11:40
  • xartaetos. Why don't you first inverte the data and then find a fitted function instead of proceeding backward as you propose ? ( If it is what your question means ). – JJacquelin Nov 18 '20 at 11:47
  • @JJacquelin Apologies for not being clear. Unfortunately I need to have both the function and its inverse. Without going into too much detail, i'm working on image processing and I'm trying to 'reverse engineer' my own algorithm. Let's say that this algorithm consists of two functions applied on some input data x so that my output y =f2(f1(x)). The two have to be implemented and applied separately. I've had to change f1 (lets say it's now f'1), so now I'm looking at how I can modify f2 so that my results stay the same. But the treatment has to go both ways so that f2inv(f1(inv(y)) = x. – xartaetos Nov 18 '20 at 11:52
  • @xartaetos. I added a numerical example to my answer in order to make my proposed solution more understandable. – JJacquelin Nov 22 '20 at 14:17

3 Answers3

0

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$.

JJacquelin
  • 66,221
  • 3
  • 37
  • 87
0

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.

G Cab
  • 35,272
0

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

JJacquelin
  • 66,221
  • 3
  • 37
  • 87