【问题标题】:How to calculate c(B|A) and c(A|B) in this particular python problem如何在这个特定的 python 问题中计算 c(B|A) 和 c(A|B)
【发布时间】:2021-11-20 03:00:17
【问题描述】:

问题:

We now calculate the synchronization between all possible pairs of rows
in the matrix. Given two lists A and B, each of N values 0 or 1, and a value tau
between zero and N, we define the synchronization index between A and B as:
       0.5 * (c(B|A) + c(A|B))
Sync = -----------------------
          sqrt(m(A)*m(B))
Where:
    - c(B|A) is the number of times an accent of B is preceded by an accent of A
      within a distance <= tau
    - c(A|B) is the number of times an accent of A is preceded by an accent of B
       within a distance <= tau
    - m(A) is the number of accents in A
    - m(B) is the number of accents in B
and where, remember, a value of 1 in A or B represents an accent
NOTA: if m(A) == 0 o m(B) == 0 then we assume zero Sync
For example, given the two sequences and value of tau:
    - A = [0, 0, 0, 0, 1, 0, 0, 1]
    - B = [1, 0, 1, 0, 1, 0, 0, 0]
    - tau = 3
we will obtain:
    - c(B|A) = 1, as only the third accent in B (position 4) is preceded in A by a
    accent within 3 positions (in this case the 1 in A has the same position
    as the 1 in B)
    - c(A|B) = 2, as both accents of A are preceded in B by two accents within
    3 positions
    - m(A) = 2
    - m(B) = 3
    - Sync = 0.5 × (1 + 2) / sqrt(2×3) = 0.6123724356957946

[c(B|A) 和/或 c(A|B) 是如何计算的,请解释一下]

[重音为 1,因此第三个重音表示列表中的第三个“1”(因此 B 的第三个重音表示列表 B 中的第三个“1”,即位置 4(B[4]==第三个重音))

我试图了解它是如何计算的,但我很困惑

【问题讨论】:

    标签: python logic calculation


    【解决方案1】:

    这个问题措辞不是很好,我同意。

    “A 有重音”只是意味着A[i] 是一个。 m(A) = 3m(B) = 2 因为 A 中有三个 1,B 中有两个 1。

    m(A|B) 表示存在 1 的次数是 A 并且在相应的数组 B 中,在该位置或在前三个位置之一存在 1。如果您查看数组 A 中的两个 1,则 B 中的 1 要么在同一位置,要么在前三个位置之一。

    对于 B 也是如此。B 中的前两个 1 在 A 中都没有对应的 1。


    请注意,您似乎在问这个问题的含义。我希望我向你解释了。如果您要求我们为您编写代码,抱歉,我们不这样做。

    【讨论】:

    • 谢谢弗兰克,我需要一个解释,你的,真的帮助了我
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-05
    • 2015-11-28
    • 1970-01-01
    • 2014-01-15
    • 2011-05-30
    • 2011-08-01
    相关资源
    最近更新 更多