[Tutor] comparing seqs by successive intervals
kevin parks
kp8 at mac.com
Mon Jan 19 01:58:38 EST 2004
Don asks:
> Forgive my asking, but what would this sort of comparison be used for?
> The
> problem seems strange enough to make it sound an awful lot like a
> homework
> assignment.
It would be used for comparing musical sequences to see if they are
related by transposition or inversion (get to that later). Two musical
sequences that have different pitches are related by transposition if
their interval sequences are the same. I would be using this to test
for that condition.
It is not a homework assignment. It is just something i am trying to
hack together for my own personal
library of python modules. Mostly cause i am insane and do this on a
sat night for fun.
Lee suggests:
> How about "normalizing" each list?
>
>>>> seq01 = [5, 7, 8, 11]
>>>> s01 = [s - seq01[0] for s in seq01]
>>>> s01
> [0, 2, 3, 6]
>>>> seq02 = [1, 3, 4, 7]
>>>> s02 = [s - seq02[0] for s in seq02]
>>>> s02
> [0, 2, 3, 6]
>
Actually I am doing something similar to this in some other code. I
have something that removes duplicates and sorts the items beforehand,
then normalizes as above. And of course normalizing will show that
there are indeed transpositions (i have code that does this too) but i
was intrigued and puzzled by this idea of measuring the intervals
between successive list items and wanted to see how that could be done
and then compared to another list, because i eventually find a way to
see how far away the transposed items are.... eventually.
I see that Don has sent something like is close to what i am trying to
do, only his seems to work *^-^*, I am going to look at that now.
Thanks for the responses.
-kevin
More information about the Tutor
mailing list