计算集合中每个系列都已定义的连续点数

Counting the number of consecutive points where each series in a set are all defined

如果我有两个(或更多...)"sparse" 系列(即不一定在每个时刻都定义)和一个特定的时间范围,我可以使用什么技巧来找到最大数量的定义数据"synchronized interval" 中的点(即系列的 all 已定义或未定义)?

例如以下三个系列:

    t: 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
   ----------------------------------------------------
   s0: 1  -  -  1  6  -  2  -  2  8  -  9  0  -  -  -
   s1: 3  -  -  4  0  -  3  2  3  3  -  1  1  -  -  7
   s2: 1  -  -  5  9  -  2  4  -  3  -  2  4  4  -  -
       ^-----------------^        ^--------^
count: 1........2..3....[4]       1.....2.[3]

我们会发现在 "synchronized interval."

中定义的最多 4 个数据点

经过多次实验,我得出了一个解决方案——假设有两个系列 s0 和 s1(尽管这可以推广到任意数量的系列):

$NUM_SERIES = 2
$NUM_SERIES_RECIPROCAL = 1/2
sum = sumSeries(isNonNull(s0),isNonNull(s1))

removeBelowValue(
  derivative(
    transformNull(
      keepLastValue(
        multiplySeries(
          transformNull(
            keepLastValue(
              integral(
                scale(
                  removeBelowValue(sum, $NUM_SERIES),
                  $NUM_SERIES_RECIPROCAL
                )
              )
            ),
            0
          ),
          scale(
            removeAboveValue(
              derivative(
                keepLastValue(
                  removeBelowValue(
                    sum,
                    1
                  )
                )
              ),
              -1
            ),
            -1
          )
        )
      ),
      0
    )
  ),
  1
)