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