10.1
import numpy as np
import scipy.linalg as lin

A=np.random.randn(20,15)
b=np.random.randn(20)
c,re,rand,sigma=lin.lstsq(A,b)
b_=A.dot(c)

print(lin.norm(b-b_))

python homework——the 13th week

10.2
import numpy as np
import scipy.optimize as opt
def f(x):
 return -np.sin(x-2)**2 * np.e**(-x**2)
min_=opt.fmin(f,0)
print(-f(min_)[0])

python homework——the 13th week

10.3
import numpy as np
import scipy.spatial.distance as dis

X=np.random.randn(10,8)
print(dis.squareform(dis.pdist(X)))

position=np.random.randn(10,2)
print(dis.squareform(dis.pdist(position)))

python homework——the 13th week


相关文章:

  • 2022-01-13
  • 2021-07-03
  • 2022-02-02
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2021-09-13
  • 2021-08-30
猜你喜欢
  • 2021-09-20
  • 2022-01-23
  • 2021-09-15
  • 2022-03-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案