On Wed, Mar 26, 2014 at 1:28 PM, Slaunger <slaun...@gmail.com> wrote:

See if you can make sense of the following. It is a little cryptic, but it
works:

f_change = np.array([2, 3, 39, 41, 58, 59, 65, 66, 93, 102, 145])

g_change = np.array([2, 94, 101, 146, 149])

N = 150


if len(f_change) % 2 :

    f_change = np.append(f_change, N)


if len(g_change) % 2 :

    g_change = np.append(g_change, N)


idx = np.searchsorted(f_change, g_change)


f_change_exp = np.insert(np.insert(f_change, idx, g_change),

                         idx + np.arange(len(idx)), g_change)


idx2 = np.searchsorted(g_change, f_change_exp)


f_change_lens = f_change_exp[1::2] - f_change_exp[::2]

true_true_intervals = idx2[1::2] % 2 != 0


total = np.sum(f_change_lens[true_true_intervals])


>>> total

9

I'll gladly elaborate on what's going on, just ask!

Jaime

-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes
de dominación mundial.
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to