Reputation: 12004
I have a set of experimental values. For instance, I have a value of 1120 pixels and I need to have some kind of factor z to multiply these 1120 pixels to get a value of approximately 1.15. Furthermore, I have 800 pixels and need to multiply this with the same factor z to get a value of approximately 1.2. Here are my experimental values:
1120 * z = approximately 1.15
800 * z = approx. 1.2
720 * z = approx. 1.25
640 * z = approx. 1.3
560 * z = approx. 1.4
480 * z = approx. 1.5
320 * z = approx. 2.0
I don't need values below 1.15 or above 2.0.
So my question is how I determine how big z is. This looks to me a little bit exponential, but I have no idea how to handle this in Objective-C. Any help would be very much appreciated.
Upvotes: 0
Views: 205
Reputation: 5953
Try Wolfram Alpha. Typing best fit {1120,1.15},{800,1.2},{720,1.25},{640, 1.3},{560,1.4}, {480,1.5}, {320,2.0} into wolfram alpha gives you a cubic equation with a .998 R^2 value, vs 99.2 exponential. But it all depends on what your underlying model is. Nice thing on Wolfram is you can modify your input data and see how sensitive the equation is to possible errors.
Upvotes: 1
Reputation: 13296
It looked exponential to me as well. I figured this out using Grapher.
Since Grapher is bad at interpolating exponential functions, I plotted the points and modified an exponential equation till I got it pretty close. Then I entered the values I found as the starting point for the interpolation. The equation that you can use in your app is:
4.3069 * powf(M_E, -x/200.0f) + 1.1327f
Upvotes: 2