我想绘制以下累积分布函数

要做到这一点,我认为可以使用np.piecewise,如下所示
x = np.linspace(3, 9, 100)
np.piecewise(x, [x < 3, 3 <= x <= 9, x > 9], [0, float((x - 3)) / (9 - 3), 1])但这会给出以下错误
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()我该怎么做呢?
发布于 2017-02-15 00:49:13
np.piecewise是一头反复无常的野兽。
使用:
x = np.linspace(3, 9, 100)
cond = [x < 3, (3 <= x) & (x <= 9), x > 9];
func = [0, lambda x : (x - 3) / (9 - 3), 1];
np.piecewise(x, cond, func)解释here。
https://stackoverflow.com/questions/42231156
复制相似问题