从某些向量创建价值对
假设我们有一对类似以下的对,并且每对都带有一个附加的值。毫无疑问,对(1,2)
是2.5
。 还有另一组p1
代表一组人。每个人都连接到一组对。例如,对于p1 中的p,它们的关联对是
p1_pairs
(即[(1,2),(1,1,7),(2) )]
Pairs = [(1, 2), (1, 7), (2, 3), (2, 5),(3, 4), (3, 5), (4, 1), (4, 5), (5, 2)]
Values = [ 2.5, 4.1, 7.4, 5.6, 2.8, 3.7, 6.9, 0.2, 3.2 ]
P1 = ['p','q']
p1_pairs = [ [(1, 2), (1, 7), (2, 3)],
[(1, 2), (2, 3), (2, 5) ,(5, 2)]
]
, 3
。 1,2)] = 2.5 和person_values ['q',(2,3)] = 7.4
。 换句话说,person_values
将通过p1
和p1_pairs
索引索引,然后根据其value将相应值分配给它们。
Suppose we have a set of pair like the following, and each pair comes with a value attached to it. For isntance the value of pair (1,2)
is 2.5
.
There are another set p1
which represent a set of persons. Each person connected to set of pairs. For instance, for p in p1
their associated pairs are the first elemenst of p1_pairs
(i.e. [(1, 2), (1, 7), (2, 3)]
.
Pairs = [(1, 2), (1, 7), (2, 3), (2, 5),(3, 4), (3, 5), (4, 1), (4, 5), (5, 2)]
Values = [ 2.5, 4.1, 7.4, 5.6, 2.8, 3.7, 6.9, 0.2, 3.2 ]
P1 = ['p','q']
p1_pairs = [ [(1, 2), (1, 7), (2, 3)],
[(1, 2), (2, 3), (2, 5) ,(5, 2)]
]
The question is, how to bulid up a parameter person_values
such that it return the value of the associated pairs?
For instance person_values['p',(1, 2)] = 2.5
and person_values['q',(2, 3)] = 7.4
.
In other words person_values
will be indexed over elemets of p1
and p1_pairs
and then assign s the corresponding values to them based on their values
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解您的问题,您想要这个:
If I correctly understood your question you want this: