感受对数函数与十进制的变化快慢 import numpy as np #设置小数位置为4位,并且不以科学计数法显示 np.set_printoptions(precision=4,suppress=True) # 个,十,百,千, 万, 十万, 百万, 千万, 1亿 a=np.array([1,10,100,1000,10000,100000,1000000,10000000,100000000]) print(np.log(a).astype(np.float32)) """ [ 0. 2.3026 4.6052 6.9078 9.2103 11.5129 13.8155 16.1181 18.4207] """ print(np.log2(a).astype(np.float32)) """ [ 0. 3.3219 6.6439 9.9658 13.2877 16.6096 19.9316 23.2535 26.5754] """ b=np.array([1.0001, 2, 癣np.e, 5000, 33333333]) print(np.log(b)) # [ 0.0001 0.6931 1. 8.5172 17.3221] print(np.log2(b)) # [ 0.0001 1. 1.4427 12.2877 24.9905] print(np.log2(b)/25) # [0. 0.04 0.0577 0.4915 0.9996] |
|
|
|
一个近似的峰附近可能有一个正弦函数 from matplotlib import pyplot as plt import numpy as np x=np.arange(20,step=0.1) # y = np.sin(x) # plt.plot(x,y) # y = np.sin(2*x) # plt.plot(x,y) # 一个近似的峰附近可能有一个正弦函数 y =np.sin(5*x)+ np.sin(2*x) + np.sin(x) plt.plot(x,y) ![]() |