6

Is there any way to find a function, even just similar, from a set of values?

I get these pairs of values from two sensors and would like to find a simple function that describes the relationship between these pairs of numbers and then to estimate the values without having to take each time.

I have a "black box" sensor, connected to a potentiometer that gives me a value for the direction of a servo, I noticed that the value is offset by a number (eg 200 -> 11, 72 -> 5) and I wanted to understand if it was possible to solve this error from outside this box approximating the value of error that could return from a given parameter.

example: I have some values (x, y):

{(200, 11), (72, 5), (36,3), (28,3), (18,2), (12,2), ...}

what is the function that can return these values and all others who follow this trend on a graph, more easily and better possible?

thank you, hello!

miracle173
  • 11,359
frx08
  • 185
  • 1
    Possible dupe: http://math.stackexchange.com/questions/11502/find-formula-from-values – Aryabhata Dec 03 '10 at 02:24
  • @Mo: dunno, that one was a tad simpler since his data already looked awfully linear... but I won't object if people vote to close this one. – J. M. ain't a mathematician Dec 03 '10 at 02:26
  • I get these pairs of values from two sensors and would like to find a simple function that describes the relationship between these pairs of numbers and then to estimate the values without having to take each time, but I can not get values in a sequence where x = 1,2,3 , 4 ... as in that question – frx08 Dec 03 '10 at 02:40
  • @J.M: Yes, I did not cast a close vote because I wasn't sure. – Aryabhata Dec 03 '10 at 05:11
  • 1
    Can you describe exactly what these sensors do? Some people here are very good in physics and might be possible to extract theoretical relations. – AD - Stop Putin - Dec 03 '10 at 05:18
  • I have a "black box" sensor, connected to a potentiometer that gives me a value for the direction of a servo, I noticed that the value is offset by a number (eg 200 -> 11, 72 -> 5) and I wanted to understand if it was possible to solve this error from outside this box approximating the value of error that could return from a given parameter. Thanks to all. EDIT: I found this tool, It could help me? xuru.org/rt/NLR.asp – frx08 Dec 03 '10 at 10:28

1 Answers1

8

Assuming those values came from a polynomial, what you want to do is polynomial interpolation.

In this case, since you have six points, the degree of the polynomial is at most five, since six coefficients are needed to uniquely determine a quintic.

Wolfram Alpha is able to determine interpolating polynomials from given data, e.g. this.

  • thanks very much, is there a way to find a simple function that comes close to this graph? eg. totally random f(x) = ln|2x+3/5x^2| – frx08 Dec 03 '10 at 02:48
  • 1
    @frx: That is in more ways than one a more difficult question. If you don't have a "guess" already, it's hard to tell since many different functions can generate the same data. – J. M. ain't a mathematician Dec 03 '10 at 02:51
  • 1
    J.M., I don't think the interpolating polynomial is what the OP is looking for. It sounds to me like he wants some kind of regression. – Qiaochu Yuan Dec 03 '10 at 03:21
  • @Qiaochu: without knowing either the physical process that generated the data, or making an assumption on the form of the function that generated the data, your guess is as good as mine. – J. M. ain't a mathematician Dec 03 '10 at 05:04
  • 1
    I have a "black box" sensor, connected to a potentiometer that gives me a value for the direction of a servo, I noticed that the value is offset by a number (eg 200 -> 11, 72 -> 5) and I wanted to understand if it was possible to solve this error from outside this box approximating the value of error that could return from a given parameter. Thanks to all. EDIT: I found this tool, It could help me? http://www.xuru.org/rt/NLR.asp – frx08 Dec 03 '10 at 10:25
  • I found the solution, I used that tool and it returns me that the best approximation function is y=4.825631721·10^-2 x + 1.389697969 so I used wolframalpha to calculate it and the results is y = 0.0482563 x+1.3897 that gave me a efficient approximation (I tested it whit new values in the sensors :)) – frx08 Dec 03 '10 at 10:36
  • @frx: You didn't mention that you were assuming that $y$ linearly varies (or is supposed to) with $x$ (and thus your data is contaminated with error). :) – J. M. ain't a mathematician Dec 03 '10 at 10:40
  • sorry, but I didn't think this could affect the solution ;) – frx08 Dec 03 '10 at 16:57
  • @frx: Remember the mantra: "garbage in, garbage out" :) – J. M. ain't a mathematician Dec 04 '10 at 02:24
  • The link doesn't work anymore, @frx08. – Shaun Oct 09 '24 at 10:53