遇到從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