Dimensionality reduction (mixing the rational and irrational)

After all the temporal/morphology talk in the AudioGuide thread I decided to revisit this thread and idea, and wanted to figure out the linear regression stuff anyways.

I shall save you the details of me trying to understand how to implement linear regression in Max, but mercifully one of @Angela’s friends is an MIT’d data scientist, and he held my dumbdumb hand through the process…

But here is a Max implementation of the slope output of linear regression (based on a translation of this javascript code):


----------begin_max5_patcher----------
10086.3oc68s1aikbcsetmeELB2Oknou06G4SW63DGfXmDD6KLtv3hFTRr0v
YnHEHo5oaGj7aOqUU6CEoDOjEkN5gM7X2pUedtqcser1ONU8e9ce3rKV70Iq
Naze+n+3nO7g+yu6CenbHdfOH+6Ob1Mi+5kyFupbYmM+tatXxxyNudpaGu9x
eX57q+zxIWtt9Xb93GUmOJo9nOoBZsSi+3C4v4i7JdFi4ipQ++kGvh6VOax5
0e61I069ryNezYWLd90ms4RldU4Eu3he76MV08u4kiuYx5IK+zj4iuXV41Ux
4.MNcNdrEJVe+AqurxQM7f+We22webdiC8KWbyMSlutiBVO4qkg7YWMY4zuL
d8zuL4ueC0sbxJbo3fKl+oYSmO4xE2Mub0l94b1j9i9yG4xwO5R1TLF03Opr
2b9nfsv5Taw51luXRm09XW8DF6ed1B7P1LzWNESQ6xz2mnfKUGPgGOfx5mhr
.44WtX1hk0qnHOc+Oz8wchsH074EKuYbgxCGhWdw06P.ly24G2S.Oe4s4S9Y
P9ORb61Q2LY77+sO+q1H1c1QmBzQ+G8XNHDRN7mnMBpUq8GeN.S7jorW1Z3D
D5zaSiSVJCaYbCl+zYS9xjkqf9xVW8GNa7s2t0g+vV2BYV+XcdHc9lCMcd8P
5MGZ4juLs698aN53kfSsFro6VVFom80f6r6eLKfN876lVdR0ChoMgjJSPygX
zpaGeY8l47X2oum26yEgRkqvkCF9Wtr+dtMElls3xeZxUaIGh4famLe57sMg
ryouZxmGe2r0e5yKlud0z+TgBz7gumy+YgB26I4XnP9+BnNOay.35kSuZwbR
D6LSvC2859iiphN5cFLkqX93a2yMC4EvV54jqvf7t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re0Fs+9VPpmhQbwrIvkYs.f+xEK9oyFH
iS+3sSm+SmZ4xvnT1LLJiZtjf5NPdWa352aztM7Zdj3680xnb41s+si6PngW
4iLy1v8zmJw467yAHOvsSSuh1eG3JY7vD+dLubChZxOUiI6OvV64sFrzLBk3
3Pn2qJ0FO39M1E6l4OTtQTYmzIJYtwPJ+VLMnQ8by3uF32T8oYLJsabKQQV7
4UOmcF+OXhb3.FxAb4Svt8n7LVuIuqeMJ9qG54gcVHS2Og8T3pOaXhoMMnwi
+sCXqJlRxVc2i+sWQW7Om9TaWsi1lEqeJ+mVR21pm9F77ZTWSD9kytax2qO0
VoSGkZQeuMr71VtFRBb4hed9ISgG015.Rg+Cea7oSfJtR0WMRx8QiptCWIzs
COA9qWNYxSfBKbuMohi6Fal3vSb+VXYa95wmL4U1wrksNEkttKxFC4xlQ0PS
i+GSt5jou3Fja5Mw+nDOFCM88+axrYK94SmEZ70lRJl1r6iAoR+wZlMeVoRu
DC.yeNN.Jku3WuX1SPDYSJj7.wjrjqO3ss1s2s71YOMvCwMcSmS6C0UzdtcX
G8GAgpSUAFY7JYWdyvMEtzPNtVN4xIS+xgqb29jY1DXx8iI018W5vPb0PTnX
Qyd7Cb2fJKNBhRmBCo4r8fb6WGonUSle0p2adPtmIO75d6sMiUQYi+KacxVl
F2q2zCpry5w2drN4dqjQ8aFudwneCiB8rA68uZ8jOe2rYqOsBrvOZk59TUXC
Vcl5iG18oOrwFSdecaQi6Sj0cQOtSxXBCKSsNndgFSCX78lTLUA1X2n5X41M
8fZ8b8jUuu9dA9YlMmucpsAPYWXKVSamUlWfxsTkllx6PieuA6Nv4xA2Qxnn
NmUAY6qz3jZsGTp5lrbdmG7V5y+poKW+sQ+iWu3IoNW+z4JUviOyU2JSgk0G
uu6+569e.gJmv1
-----------end_max5_patcher-----------

Here is the relevant code:

function linearRegression(y,x){
        var lr = {};
        var n = y.length;
        var sum_x = 0;
        var sum_y = 0;
        var sum_xy = 0;
        var sum_xx = 0;
        var sum_yy = 0;

        for (var i = 0; i < y.length; i++) {

            sum_x += x[i];
            sum_y += y[i];
            sum_xy += (x[i]*y[i]);
            sum_xx += (x[i]*x[i]);
            sum_yy += (y[i]*y[i]);
        } 

        lr['slope'] = (n * sum_xy - sum_x * sum_y) / (n*sum_xx - sum_x * sum_x);
        lr['intercept'] = (sum_y - lr.slope * sum_x)/n;
        lr['r2'] = Math.pow((n*sum_xy - sum_x*sum_y)/Math.sqrt((n*sum_xx-sum_x*sum_x)*(n*sum_yy-sum_y*sum_y)),2);

        return lr;
}

I also included a vanilla Max version of the mean of the derivative of loudness, to compare the results, along with an option to omit the first frame (which would generally be an uptick).

The included coll dataset has hits from brushes.aif, jongly.aif, and some of my prepared snare stuff, so it’s a cross section of diff types of percussive/drum attacks, and across a fairly wide range of hits, the slope seems to more accurately capture the temporal shape.

When you have symmetrical samples, the results are pretty much the same:
Screenshot 2020-07-10 at 11.21.13 pm

But for things like this, the slope wins out in terms of giving you an idea of what the overall analysis window is doing:

Screenshot 2020-07-11 at 12.30.12 am

Screenshot 2020-07-11 at 12.30.29 am

edit:
original screenshots changed since I realized I wasn’t processing the same list of numbers for both.

Although I haven’t implemented it in my code above, there is also the r2 value, which can function in a similar way to the pitch confidence metric, so the higher the r2 value, the tighter the samples fit the slope.

So, I’m thinking of including this as another metric in the timeness descriptor, perhaps also incorporating the r2 as a weighting option for it, so the higher the r2, the more the slope is reflected in the overall timeness value.

I also imagine that you’re in crunch time leading up to the plenary, but wanted to check on your amountOfPipe-ness as to the overall concept here.