Linear Regression

大学时候学物理实验的时候接触过线性回归,现在忘记了...还得重新拾起来。学习不扎实耽误了多少时光... sigh

Suppose that you time a program as a function of N and produce
the following table.

        N   seconds
-------------------
       64     0.000
      128     0.001
      256     0.010
      512     0.083
     1024     0.698
     2048     5.742
     4096    48.346
     8192   401.315
    16384  3366.172


Estimate the order of growth of the running time as a function of N.
Assume that the running time obeys a power law T(N) ~ a N^b. For your
answer, enter the constant b. Your answer will be marked as correct
if it is within 1% of the target answer - we recommend using
two digits after the decimal separator, e.g., 2.34.

已知一组数据,N和seconds, 求T(n)中的b。

方法是两边先取对数,这样造成 log(T(n)) = log(a) + b * log(n), 这样就完成了一个斜率b的线性函数。我们用一般的线性回归就可以解出b和a。

Reference: 

https://en.wikipedia.org/wiki/Regression_analysis

posted @ 2016-02-02 11:46  YRB  阅读(258)  评论(0编辑  收藏  举报