【发布时间】:2014-07-23 17:02:34
【问题描述】:
目前我使用以下代码创建了垃圾箱:
bin_volumes = [((i+1)**3 - i**3) * bin_width**3 *4 * np.pi/3 for i in range(num_bins)]
bin 格式:
[(0.0, 0.10000000000000001), (0.10000000000000001, 0.20000000000000001), (0.20000000000000001, 0.30000000000000004), (0.30000000000000004, 0.40000000000000002), (0.40000000000000002, 0.5), (0.5, 0.60000000000000009), (0.60000000000000009, 0.70000000000000007), (0.70000000000000007, 0.80000000000000004), (0.80000000000000004, 0.90000000000000002), (0.90000000000000002, 1.0), (1.0, 1.1000000000000001), (1.1000000000000001, 1.2000000000000002), (1.2000000000000002, 1.3), (1.3, 1.4000000000000001), (1.4000000000000001, 1.5), (1.5, 1.6000000000000001), (1.6000000000000001, 1.7000000000000002), (1.7000000000000002, 1.8), (1.8, 1.9000000000000001), (1.9000000000000001, 2.0), (2.0, 2.1000000000000001), (2.1000000000000001, 2.2000000000000002), (2.2000000000000002, 2.3000000000000003), (2.3000000000000003, 2.4000000000000004), (2.4000000000000004, 2.5), (2.5, 2.6000000000000001), (2.6000000000000001, 2.7000000000000002), (2.7000000000000002, 2.8000000000000003), (2.8000000000000003, 2.9000000000000004), (2.9000000000000004, 3.0), (3.0, 3.1000000000000001), (3.1000000000000001, 3.2000000000000002), (3.2000000000000002, 3.3000000000000003), (3.3000000000000003, 3.4000000000000004), (3.4000000000000004, 3.5), (3.5, 3.6000000000000001), (3.6000000000000001, 3.7000000000000002), (3.7000000000000002, 3.8000000000000003), (3.8000000000000003, 3.9000000000000004)
数据格式:
3.615
4.42745271008
2.55619101399
2.55619101399
2.55619101399
4.42745271008
3.615
2.55619101399
4.42745271008
5.71581687075
5.71581687075
3.615
2.55619101399
2.55619101399
2.55619101399
2.55619101399
2.55619101399
2.55619101399
我希望能够在每次数据点适合 bin 范围时添加一个,以便我可以收集每个范围的“频率”,然后使用它来创建图表。
创建数据的代码:
for b in range(2047):
for a in range(b+1,2048):
vector1 = (l[b][0],l[b][1],l[b][2])
vector2 = (l[a][0],l[a][1],l[a][2])
x = vector1
y = vector2
vector3 = list(np.array(x) - np.array(y))
dotProduct = reduce( operator.add, map( operator.mul, vector3, vector3))
dp = dotProduct**.5
data = dp
【问题讨论】:
-
你能解释一下数据的格式吗?这些行在文件中吗?它们是
numpy数组中的值吗?不清楚。 -
是的,这里我会提供创建数据集的代码,但是我相信它是一个numpy数组。