遇到从this post据我所知,在那里进行评估之前,LOG10()计算。简单地说,我不明白这个问题提供了答案。也是为什么会在日志10()先评估,当然这只是导致不必要的计算?NumPy的RuntimeWarning:被零除在日志10
merge_y = np.where(N = < 1,1,N * np.log10(n))的
import matplotlib.pyplot as plt
import numpy as np
n = np.arange(0, 10, 0.0001)
merge_y = np.where(n <= 1, 1, n * np.log10(n))
insertion_y = n*n
plt.plot(n, merge_y,'g')
plt.plot(n,insertion_y,'r')
plt.grid(True)
plt.xlabel('n')
plt.ylabel('T(n)')
plt.title('Time complexities of merge and insertion sort w/ input size n')
plt.show()
你一定要明白,你试图计算'LOG10(0)',对吧? – cel
我不能看到,对于(条件A,B)的心不是B如果条件为假并且如果这是真的回来... – trunks1ace