Edwinlr 发表于 2009-4-16 09:04

1stopt 带约束的拟合问题

我先说下题目.条件约束是,待拟合函数及它的导数过一个已知点.
我的题目的拟合函数是y =527-215*exp(-m*x^n); 过的已知点是x=0.1624717,y=527.068036(数据最后一行)

编写程序如下:(导数我自己手算的)

请各位帮我看下有什么问题吗.我用的是1.5版本.

Variable x, y;
constant x1=0.1624717,y1=527.068036;
Parameter m,n;
Function y =527-215*exp(-m*x^n);
         y1=527-215*exp(-m*x1^n);
         y1=-215*exp(-m*x1^n)*(-m*n*x1^(n-1));
Data;
0.0035711 312.2771892
0.0037729 314.8637028
0.0039895 317.2852979
0.0042211 319.5088295
0.00446 321.597142
0.0047139 323.6038375
0.0049826 325.422406
0.0052661 327.1372123
0.0055496 328.7845602
0.0058479 330.3119839
0.0061535 331.7873942
0.0064665 333.2892772
0.0067795 334.6913551
0.0071072 336.0217016
0.0074422 337.3231203
0.0077623 338.5759527
0.0081194 339.9107132
0.0084616 341.1303304
0.0087962 342.3632898
0.0091604 343.5940924
0.0095394 344.8611114
0.0098736 346.0044981
0.0102374 347.1861585
0.0106011 348.3797042
0.0109721 349.598862
0.0113652 350.8256212
0.0117655 352.0851894
0.0121731 353.3806635
0.0125805 354.6244181
0.0129804 355.851238
0.0133727 357.063108
0.0137944 358.3310316
0.0141864 359.5182615
0.0146004 360.7285163
0.0150142 361.9447253
0.015487 363.3122554
0.0159299 364.5807361
0.0163875 365.8759269
0.0168817 367.2548467
0.0173609 368.5939031
0.0178178 369.8485314
0.0183334 371.2258282
0.0188193 372.562809
0.0192755 373.7951008
0.0197683 375.084989
0.0203343 376.5648744
0.0208633 377.89957
0.02137 379.2271144
0.0219352 380.6384575
0.0224706 382.0113102
0.0230132 383.3237578
0.0235774 384.7318612
0.0241266 386.06497
0.0246975 387.4057648
0.0252388 388.6769844
0.0257944 389.9950723
0.0264009 391.389839
0.0269851 392.7301496
0.027569 394.0131653
0.0281743 395.3883443
0.0288304 396.8180743
0.0293986 398.0755104
0.030032 399.4118026
0.0306432 400.713914
0.0312467 401.9978879
0.0318862 403.2936388
0.0324962 404.5035571
0.0331567 405.8706737
0.033766 407.0944525
0.0344183 408.3713297
0.0351282 409.7426532
0.0358159 411.0837848
0.0365465 412.4515271
0.0372043 413.6611894
0.0378472 414.8681709
0.0385546 416.1906884
0.0392255 417.3415264
0.0399248 418.5472266
0.040638 419.8675218
0.0413794 421.1044687
0.0420413 422.2342898
0.0427673 423.4813336
0.0434856 424.6838703
0.0442322 425.8905142
0.0449853 427.0461093
0.0457666 428.3366653
0.0465472 429.571095
0.0473773 430.7991426
0.0481852 432.0634464
0.0489925 433.2945728
0.0497849 434.4462976
0.0505909 435.6665243
0.0514177 436.8753823
0.0522722 438.0759893
0.0531402 439.3485869
0.0540501 440.5908523
0.0549876 441.8651572
0.0558816 443.0725177
0.0567465 444.2475693
0.0577664 445.5368083
0.0586792 446.7421777
0.0596971 448.0410667
0.0606505 449.2430022
0.0618004 450.6289663
0.0628222 451.9117108
0.0639204 453.2066926
0.0649611 454.4522626
0.0661692 455.8595648
0.0672567 457.0828786
0.068378 458.3559477
0.0695471 459.6575195
0.0707077 460.8943358
0.0718042 462.1166456
0.0730599 463.3954689
0.0743279 464.7633024
0.0756639 466.0673744
0.0769911 467.4337459
0.078379 468.7913437
0.0796611 470.0782453
0.0810799 471.3898172
0.0823516 472.6466045
0.0837734 473.8899926
0.0851864 475.231911
0.0866248 476.5288612
0.0880887 477.8254105
0.0895984 479.1587411
0.0911949 480.5016296
0.0926316 481.7728011
0.0942505 483.1148949
0.0959009 484.4543995
0.0975286 485.7672542
0.0992615 487.1133208
0.1010934 488.5851527
0.1029148 489.997929
0.1046393 491.3010719
0.1064749 492.6531409
0.1082802 493.9779582
0.1100017 495.229808
0.1117337 496.4662139
0.1135894 497.770382
0.1154559 499.0247172
0.1174657 500.4425175
0.1193702 501.6827564
0.1214253 503.1235425
0.1235619 504.4723507
0.1254222 505.6690605
0.1273531 506.9133018
0.1293514 508.194742
0.1313861 509.4590275
0.1333825 510.6519654
0.135671 512.033797
0.1377573 513.3476526
0.1401601 514.7379184
0.1422822 515.9720669
0.1446084 517.3066097
0.146703 518.4561311
0.1490707 519.8116256
0.1514327 521.1397945
0.1534487 522.2649286
0.1556652 523.4612169
0.1579477 524.6363023
0.1602889 525.9094509
0.1624717 527.068036

dingd 发表于 2009-4-16 15:11

仅有第一个约束:
均方差(RMSE): 24.5934879306219
残差平方和(RSS): 98588.8627207643
相关系数(R): 0.981221534114178
相关系数之平方(R^2): 0.962795699009381
决定系数(DC): 0.836009298700028
卡方系数(Chi-Square): 113.423835106847
F统计(F-Statistic): 981.762982435808
约束条件: 527.068036-(527-215*exp(-m*0.1624717^n)) = 0.07774821486

参数        最佳估算
----------        -------------
m                  310.072727733747
n                  1.88951342980634

仅有第二个约束:
均方差(RMSE): 43.8289753275021
残差平方和(RSS): 313119.589756182
相关系数(R): 0.976988488842973
相关系数之平方(R^2): 0.954506507331676
决定系数(DC): 0.479163267555769
卡方系数(Chi-Square): 384.659332343799
F统计(F-Statistic): 309.117982605497
约束条件: 527.068036-(-215*exp(-m*0.1624717^n)*(-m*n*0.1624717^(n-1))) = 0

参数        最佳估算
----------        -------------
m                  20.7617516333988
n                  1.34325919627072

两个约束都满足,似乎不大可能?
页: [1]
查看完整版本: 1stopt 带约束的拟合问题