擅长:python、mysql、java
<p>你可以做一个<a href="http://en.wikipedia.org/wiki/Least_squares">least squares fit</a>的数据。</p>
<p>使用<a href="http://en.wikipedia.org/wiki/Ordinary_least_squares#Simple_regression_model">this page</a>中的公式:</p>
<pre><code>y = [12, 34, 29, 38, 34, 51, 29, 34, 47, 34, 55, 94, 68, 81]
N = len(y)
x = range(N)
B = (sum(x[i] * y[i] for i in xrange(N)) - 1./N*sum(x)*sum(y)) / (sum(x[i]**2 for i in xrange(N)) - 1./N*sum(x)**2)
A = 1.*sum(y)/N - B * 1.*sum(x)/N
print "%f + %f * x" % (A, B)
</code></pre>
<p>它会打印最佳拟合线的起始值和增量。</p>