如果数字不是列表中的数字,如何计算概率?
How to calculate the probability in the event that a number is not the one from the list?
我有一个列表:
lst = [10,20,39,50]
如何计算Python中从列表中选取的数字不是10的概率? (事件可想而知)
从列表中得到10的概率就是10在列表长度上出现在列表中的次数:
p10 = lst.count(10) / len(lst)
而得不到 10 分的概率只是补码:
p_not10 = 1 - p10
我有一个列表:
lst = [10,20,39,50]
如何计算Python中从列表中选取的数字不是10的概率? (事件可想而知)
从列表中得到10的概率就是10在列表长度上出现在列表中的次数:
p10 = lst.count(10) / len(lst)
而得不到 10 分的概率只是补码:
p_not10 = 1 - p10