Similarity/diversity measure for sequential data based on Hasse matrices: Theory and applications