0
$\begingroup$

I need to fit a function to this particular set of data points, but I can't find anything with this general form. I have found a great fit for the inverse of this graph using the form

$$x(y) = \frac{a}{b\exp{(cy-y_c)}+d}+e$$

with the values $a=25.0989,\, b=0.2459,\, c=3.1954,\, d=0.0961,\, e=2.8681,\, y_c=-2.1852$, but inverting this function gives me

$$y(x) = \left[\ln{\left(\frac{a}{x-e}-d\right)} - \ln{(b)} + y_c \right]/c$$

at, say, x = 0 or x = 265 the logarithm is undefined. How can I obtain a function valid over the entire range [0, 265]?

Data points: $$x = [0, 5, 17, 27, 38, 74, 137, 161, 184, 209, 239, 253, 265]$$ $$y = [2.8808, 0.4771, 0, -0.2218, -0.3979, -0.6990, -1.0000, -1.0969, -1.2218, -1.3979, -1.6990, -2.0000, -3.0000]$$

Edit: included data values;

Edit 2: rewrote fit equation in terms of y for coherence; added inverse function to better demonstrate the issue; added calculated coefficients;

Edit 3: change 'e' to 'exp' for clarity.

$\endgroup$
  • 1
    $\begingroup$ It would be much easier to work with the data if you give the numerical values. $\endgroup$ – Matti P. Jul 4 '18 at 6:00
  • $\begingroup$ Added the numerical values if that helps, but all I'm looking for is an analytical function with that general shape. $\endgroup$ – Matheus Leão Jul 4 '18 at 6:30
  • $\begingroup$ I don't see the problem with inverting your $f(x)$. You subtract $e$, invert, multiply by $a$, subtract $d$, divide by $b$, take the log, add $x_c$, and divide by $c$. $\endgroup$ – Gerry Myerson Jul 4 '18 at 6:48
  • $\begingroup$ Doing that will give me complex values for certain point. All the coefficients are positive, so popping x = 0 into that equation results in a natural logarithm of a negative number, which doesn't have a real answer. $\endgroup$ – Matheus Leão Jul 4 '18 at 8:49
  • $\begingroup$ Are you using $e$ with two meanings: Euler's $2.71828\ldots$ and your calculated $2.8681$? $\endgroup$ – Henry Jul 4 '18 at 9:05
0
$\begingroup$

Even though I didn't find a better analytical solution, most of my data points ended up falling within the range of the logarithm function, so I just defined a piecewise function instead, setting the values I wanted for outlier points. An ugly solution, but works.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.