Compare lists with a bit of fuzz...

kflak's icon

Can anybody help me with this problem: I want to compare incoming lists of 6 floats (readings from two different movement sensors) with one (or many) previously recorded lists. However, I need the comparison to be done in a fuzzy way, so that you wouldn't need to hit the exact same list for the comparison to be triggered. Basically I need to compare 6 floats to 6 ranges of floats. i was thinking of using a bunch of split objects to define ranges for each of the values, but it seems a bit kludgy to do so. I could imagine this would work with some kind of javascript solution, but I don't really know how to code in javascript. So any idea on how to accomplish this using max objects only would be much appreciated. I have a feeling that the project will be more than heavy on my CPU as well, so any very elegant and computationally cheap solution would be great.

leafcutter's icon

Ok how about using vexpr to subtract the two lists, using abs we can get an absolute value for the differences between the list items.

'sort -1' will re-arrange the list with the biggest deviation first

Max Patch
Copy patch and select New From Clipboard in Max.

then just chop off the first deviation with 'slice 1' and compare it to your fuzz amount to see if there is a fuzzy match.

kflak's icon
Max Patch
Copy patch and select New From Clipboard in Max.

@Leafcutter: Wow, that's just sooooo much more elegant than the solution I contrived.... Thanks a lot! For your amusement, here's what I came up with (and will probably discard now :-))

leafcutter's icon

Wonderful, there a million and one ways to skin a max cat.

Once you get into vexpr and the zl objects you can make your life a lot more compact!

kflak's icon

So it seems :-) Thanks again. Your solution is now the backbone of my patch (with a lot of tweaks and changes, but the basic idea is there...)