5
$\begingroup$

Weighting matrices appear in the statistical design of experiments (Weighting Matrices and Statistical Design of Experiments.

A weighting matrix is a generalization of Hadamard matrices, e.g.,

HadamardMatrix[8]

HadamardMatrix[8].Inverse[HadamardMatrix[8]]

HadamardMatrix[5]

but can have zeroes as entries in addition to -1 and +1--and they exist for square matrices that are not 4*(positive integer).

Beyond a random search which is trivial and not a great method, does anyone know how to compute a Weighing matrix of size (general positive integer)?

$\endgroup$
1
  • $\begingroup$ n.b., this won't scale: With[{size = 4}, Select[Tuples[Tuples[{-1, 0, 1}, size], size], Block[{diagQ = Transpose[#] . #, diagonals}, diagonals = Diagonal[diagQ]; DiagonalMatrixQ[diagQ] && AllTrue[diagonals, # == First[diagonals] &] ] &] ] $\endgroup$ Feb 16 at 16:03

1 Answer 1

3
$\begingroup$

Here is a straightforward approach for small (less than $4$) n and w:

ClearAll[a, A]; A = Table[a[i, j], {i, 4}, {j, 4}];
FindInstance[A . Transpose[A] == 2*IdentityMatrix[4] && Flatten[A] >= -1 && 
Flatten[A] <= 1, Flatten[A], Integers]

{{a[1, 1] -> -1, a[1, 2] -> -1, a[1, 3] -> 0, a[1, 4] -> 0, a[2, 1] -> -1, a[2, 2] -> 1, a[2, 3] -> 0, a[2, 4] -> 0, a[3, 1] -> 0, a[3, 2] -> 0, a[3, 3] -> -1, a[3, 4] -> 1, a[4, 1] -> 0, a[4, 2] -> 0, a[4, 3] -> -1, a[4, 4] -> -1}}

For many n and k a weighting matrix does not exist and the above code derives it. For example, FindInstance[ A . Transpose[A] == 5*IdentityMatrix[4] && Flatten[A] >= -1 && Flatten[A] <= 1, Flatten[A], Integers] results in {}.

$\endgroup$
1
  • $\begingroup$ Nice. I wish I'd thought of FindInstance. I'll wait a couple days to accept as answerd to see if someone has a method that scales to larger n and w. $\endgroup$ Feb 16 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.