Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One option would be to do a <a href="http://en.wikipedia.org/wiki/Linear_regression">linear regression</a> on the data set to get a best-fit line. If the data is linear, you'll get a very good fit and the <a href="http://en.wikipedia.org/wiki/Mean_squared_error">mean squared error</a> should be low. Otherwise, you'll get an okay fit and a reasonable error.</p> <p>Alternatively, you could consider transforming the data set by converting each point (x<sub>0</sub>, x<sub>1</sub>, ..., x<sub>n</sub>, y) to (x<sub>0</sub>, x<sub>1</sub>, ..., x<sub>n</sub>, e<sup>y</sup>). If the data was linear, now it will be exponential, and if the data was logarithmic, now it will be linear. Running a linear regression and getting the mean-squared error now will have a low error for the logarithmic data and a staggeringly huge error for the linear data, since the exponential function blows up extremely quickly.</p> <p>To actually implement the regression, one option would be to use a <a href="http://en.wikipedia.org/wiki/Ordinary_least_squares">least-squares regression</a>. This would have the added benefit of giving you a correlation coefficient in addition to the model, which could also be used to distinguish between the two data sets.</p> <p>Because you've asked for how to do this in Java, a quick Google search turned up <strong><a href="http://introcs.cs.princeton.edu/java/97data/LinearRegression.java.html">this Java code</a></strong> to do a linear regression. However, you might have a better fit in a language like Matlab that is specifically optimized to do these sorts of queries. For example, in Matlab, you can do this regression in one line of code by writing</p> <pre><code>linearFunction = inputs / outputs </code></pre> <p>Hope this helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload