问一下关于python list的问题 请问如何比较两个LIST里数的大小?
我想做一个function比较两个list里数的大小defHistogram(A,B)A=[2,3,5,7,42]B=[3,8,45]这里小于等于3的在listA里有2个...
我想做一个function 比较两个list里数的大小 def Histogram(A,B) A = [2,3,5,7,42] B = [3,8,45] 这里小于等于3的在listA里有2个 大于等于3小于8的数有3个 大于等于8小于45的数有1个 最后的output listC = [2,3,1] 请问应该如何入手? 完全没有头绪...
原题:Histogram( [a1, ..., an], [b1, b2, ..., bk] ) returns a new list [c1, c2, ..., ck+1], where c1 is the number (count) of values in sample that are smaller than or equal to b1, ck+1 is the number of values in sample that are greater than bk, ci (for 1 < i < k) is the number of values in sample that are greater than bi and smaller than or equal to bi+1. That means that the list of values binBoundaries defines a set of bins; you can assume that the list binBoundaries for the is sorted in ascending order. The function Histogram counts (and returns) how many samples fall into each bin.
For your example
>>> t = [2, 3, 4, 5, 6, 25, 31]
>>> bins = [3, 5, 10, 30]
the output should be: [2, 2, 1, 1, 1]
2 numbers (2 and 3) are smaller than or equal to 3
2 numbers (4 and 5) are greater than 3 and smaller than or equal to 5
1 number (6) is greater than 5 and smaller than or equal to 10
1 number (25) is greater than 10 and smaller than or equal to 30
1 number (31) is greater than 30 展开
原题:Histogram( [a1, ..., an], [b1, b2, ..., bk] ) returns a new list [c1, c2, ..., ck+1], where c1 is the number (count) of values in sample that are smaller than or equal to b1, ck+1 is the number of values in sample that are greater than bk, ci (for 1 < i < k) is the number of values in sample that are greater than bi and smaller than or equal to bi+1. That means that the list of values binBoundaries defines a set of bins; you can assume that the list binBoundaries for the is sorted in ascending order. The function Histogram counts (and returns) how many samples fall into each bin.
For your example
>>> t = [2, 3, 4, 5, 6, 25, 31]
>>> bins = [3, 5, 10, 30]
the output should be: [2, 2, 1, 1, 1]
2 numbers (2 and 3) are smaller than or equal to 3
2 numbers (4 and 5) are greater than 3 and smaller than or equal to 5
1 number (6) is greater than 5 and smaller than or equal to 10
1 number (25) is greater than 10 and smaller than or equal to 30
1 number (31) is greater than 30 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询