# Find Log equation from data points

I have the following data points, (left hand column goes from 0-127, right hand column goes from 30-22000 hz. Is there any calculator I can use to find a "log" function of this data, so that it comes out in this format? e.g. " 20*(log(x*127/108))*6/3.241 "

0, 0
1, 31.6
2, 33.3
3, 35.1
4, 36.9
5, 38.9
etc.


Essentially, I'm trying to convert data points, to a logarithmic function (a polynomial one, I think :/). I know wolfram alpha has one, but it doesnt seem to offer me the right format for the equation and it also costs premium for any large amount of data points.

Cheers

K

• Do I understand the question correctly? You want to fit the data to a function of the form: $$y = \alpha log(\beta x)^\gamma$$ -- is that correct? Mar 13, 2014 at 23:06
• Sorry I explained badly. I dont want to try and fit the function. I want to find the function that describes the curve in the data set.
– Ke.
Mar 14, 2014 at 1:25
• @ Ke; : your equation 20*(log(x*127/108))*6/3.241 is not convenient. If $x=0$ you don't obtain $0$ as it is written on your data table : your formula gives -infinity. If you want to use a function of this kind, try $y(x)=a+b*\ln(x+c)$ where the parametres $a, b, c$ have to be optimized. I gave you an example in response to your other question "5th order polynomial not accurate enough , " Apr 6, 2014 at 18:05

I think the best method to fit this data is to re-express $x$ and/or $y$ so that a linear relationship can be found. Then almost every popular data tool has linear fit, like Excel, R, or wolfram alpha.

• sorry for being a bit obtuse, but im wondering how to do this linear fit? Id be really grateful for some pointers, (x is my changing data from 0-127 (which will be a float)), so Im trying to find a function that will fit that curve. Is there some tool where I can plot it? some tutorial I can follow?
– Ke.
Mar 13, 2014 at 23:16
• You try taking the logarithm of every $x$ or $y$ data point, and see if a good linear relationship appears. In excel and R this can be done with functions (for R just type log(x)). A good fit can be judged with an $r$ value or a residual graph.
– qwr
Mar 13, 2014 at 23:26
• Ive managed to get the exponential for each different x data point, but im stuck on how to turn that into a function I can use. Is there any way I can turn these data points into a function?
– Ke.
Mar 14, 2014 at 1:13

If I'm understanding correctly, your hypothesis is that the data fit a logarithmic plot. So, take the exponential of each data point, to produce a dataset that hypothetically fits a linear plot. Use least-squares regression to find the model and see if it's a nice fit. Finally, if the linear model works well, take its logarithm to produce a logarithmic model of your original dataset.

You can generalize this to the situation where the exponential of the dataset is a polynomial function, of course.

• Yes, the data does definitely fit a logarithmic plot. I am trying to convert, a linear dial into hz, which follows a logarithm. Im trying to reverse engineer the logarithm. What Im finding difficult is how to do the exponential of each data point and then how to use the least-squares regression. Im a bit limited in these areas so would be hugely grateful for some pointers into how to do these things.
– Ke.
Mar 13, 2014 at 23:59
• I see. You can either use R or excel as qwr suggests, but if you're familiar with Python, then I would recommend tossing the dataset into Sage (which is essentially Python + data structures and methods for math things, and is free). This link is a reasonable reference for your project. Even if you're not familiar with Python, the relevant material shouldn't take you too long to cover. The most obnoxious part will be the actual data entry.
– Nick
Mar 14, 2014 at 0:08
• I see, ive never hear of R before, so will give that a try and python as well as I have that set up. I tried this tool and put my numbers in alcula.com/calculators/statistics/linear-regression and it gave me " Regression line equation: y=111.48692089361x-3690.7944767442 " so I put the equation in "111 * x - 3690 " but it gives me really wrong numbers "between 3000-3500" when it should be between 30 - 20000 hz . really confused still :/ hopefully will get there eventually.
– Ke.
Mar 14, 2014 at 0:33