How do you test exactly five thresholds including both ends?
linspace samples a specified number of equally spaced points and normally includes both endpoints.
numpy.linspace in practice
Five thresholds between zero and one make four gaps of 0.25. When joining neighboring grids, check whether their shared endpoint would occur twice.
import numpy as np
np.linspace(0,1,5)Result [0.0, 0.25, 0.5, 0.75, 1.0]
中文
怎样在两个端点之间恰好测试五个阈值?
linspace 按指定点数等距取样,默认包含两个端点。
numpy.linspace 算例
从 0 到 1 取五点,中间只有四个间隔,每步 0.25。如果相邻区间要拼接,留意端点是否会出现两次。
import numpy as np
np.linspace(0,1,5)结果 [0.0, 0.25, 0.5, 0.75, 1.0]