mobile28365-365-365bet体育在线公司备用-英国365客服

数学建模

数学建模

例 2. (Kepler 第三定律) 得到的行星周期与行星到太阳的平均距离数据为:

行星 周期T 平均距离(万公里)R

水星 88.0 5791 (0.38 天文单位)

金星 224.7 10820(0.72个天文单位)

地球 365.3 14960 (1.00 天文单位)

火星 687.0 22794 (1.52 天文单位)

木星 4331.8 77833 (5.20 天文单位)

土星 10760.0 142940 (9.54 天文单位)

天王星 30684 287099 (19.218 天文单位)

海王星 60188.3 450400 (30.06 天文单位)

确定T与R的关系

Python 3.5.2 (default, Nov 12 2018, 13:43:14)

[GCC 5.4.0 20160609] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import numpy as np

>>> a=np.array([0.38, 0.72, 1.0, 1.52, 5.2, 9.54, 19.218, 30.06])

>>> b=np.array([88.0, 224.7, 365.3, 687.0,4331.8,10760.0,30684,60188.3])

>>> b/a

array([ 231.57894737, 312.08333333, 365.3 , 451.97368421,

833.03846154, 1127.88259958, 1596.6281611 , 2002.27212242])

>>> b/a**(1.5)

array([ 375.67065946, 367.79373549, 365.3 , 366.59906683,

365.31153154, 365.16547446, 364.20817565, 365.1981868 ])

Python中处理最小二乘法:可以使用 scipy库中的leastsq函数

参考: https://www.cnblogs.com/NanShan2016/p/5493429.html

相关推荐