- 积分
- 8
- 注册时间
- 2005-3-21
- 仿真币
-
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2012-1-6 15:06:34
|
显示全部楼层
来自 江苏扬州
上面的帖子看不到了,代码如下
本帖最后由 feiyuzhen 于 2012-1-6 15:10 编辑
- restart;
- with(stats);
- with(fit);
- with(statplots);
- with(plots);
- datax := [seq((rand(100))(), i = 1 .. 50)];
- datay := map(proc (x) options operator, arrow; evalf(sin((1/100)*x/Pi)+(1/100)*(rand(30))(), 4) end proc, datax);
- p1 := scatterplot(datax, datay);
- display(p1);
- leastsquare[[x, y], y = a0+a1*x+a2*x^2, {a0, a1, a2}]([datax, datay]);
- f := rhs(%);
- p2 := plot(f, x = 0 .. 100);
- display(p1, p2);
- datax1 := [1, 2, 3];
- datax2 := [2, 3, 4];
- datay1 := [3, 7, 8];
- leastsquare[[x1, x2, y], y = a1*x1+a2*x2, {a1, a2}]([datax1, datax2, datay1]);
- with(Statistics);
- f1 := Fit(a+b*x+c*x^2, datax, datay, x);
- f := Fit(a0+a1*sin((1/10)*x)+a2*sin((1/20)*x)+a3*sin((1/40)*x), datax, datay, x);
- p3 := plot(f, x = 0 .. 100);
- display(p1, p3);
- with(linalg);
- datax1 := [seq((1/100)*(rand(100))(), i = 1 .. 50)];
- datax2 := [seq((1/100)*(rand(100))(), i = 1 .. 50)];
- datax12 := zip(proc (x1, x2) options operator, arrow; [x1, x2] end proc, datax1, datax2);
- datay := zip(proc (x1, x2) options operator, arrow; x1+2*x2+cos(x1*x2)+(1/1000)*(rand(100))() end proc, datax1, datax2);
- whattype(datay);
- nops(datay);
- f4 := Fit(a1*x1+a2*x2+a3*cos(x1*x2)+a4*x1*x2, Matrix(datax12), datay, [x1, x2]);
复制代码 |
|