They can both be Nx1 vectors or NxM matrices. One can be an Nx1 vector, the other an NxM matrix, etc. W is an Nx1 vector of weights, where each row represents the weight of the corresponding row element of the portfolios. W can also be a scalar, in which case all weights are set to that scalar. M is an Nx1 vector of max distances, where each row represents the max distance of the corresponding row element of the portfolios.
M can also be a scalar, in which case all max distances are set to that scalar.
This procedure is based on the measure of similarity, S, developed in Signorino, Curtis S. and Jeffrey M. Ritter. Measuring the Similarity of Alliances and Interests. A previous version was presented at the 1997 annual meeting of the Midwest Political Science Association. In other words, the portfolios are assumed to represent the points in the N-dimensional space and the distance is calculated based on those points. Our alliance data is coded 0,1,2,3, so the max alliance distance along any one dimension is 3.