给回归方程式中A和B的计算公式:
∑Y=na+b∑X
∑XY=a∑X+b∑X2a=(∑Y-b∑X)/n 
b=(n∑XY-∑X∑Y)/(n∑X2-∑X2 )

解决方案 »

  1.   

    f(Y)=a+bX+cX*X
    用最小二乘法,求a,b,c是吗? 不难.一个SELECT就行了.
      

  2.   

    to j9988: 大虾能给出个具体的解决办法吗?to  all:
      我想要的就是二次曲线模拟
      

  3.   

    to csj43269:能麻烦你给出二次曲线模拟的公式吗???
      

  4.   

    create table t(x float,y as 9+2*x+15*x*x) 
    --利用计算列测试结果,与最后的结果比较,最后A,B,C要得到9,2,15
    --你也可以自已更改,
    --注意:实际中是存Y的正常值,而不用计算列。我这只是测试与检测结果是否正确用。
    insert t select 1 
    union all select 2
    union all select 3
    union all select 4
    union all select 5
    union all select 6
    union all select 7
    union all select 8
    union all select 9
    union all select 10
    godeclare @m float,@n int 
    --@m存放平均值 
    --@n存放记录数
    declare @b float,@a float,@c float
    declare @b1 float,@a1 float
    select @m=avg(x),@n=count(*) from tselect @b1=sum(x*y)/sum(x*x) from (select y,x-@m as x from t) A
    select @c=(sum(x*x*y)-sum(x*x)*sum(y)/@n)/(sum(x*x*x*x)-(1.0/@n)*sum(x*x)*sum(x*x)) from (select y,x-@m as x from t) A
    select @a1=(sum(y)-@c*sum(x*x))/@n from (select y,x-@m as x from t) A
    select @a=@a1-@b1*@m+@c*@m*@m,@b=@b1-2*@m*@c
    select @a,@b,@c