Using Mathematica to automatically reveal matrix structure

I spend a lot of time on larger matrices (10x10, 20x20, etc.), which usually have some structure, but they are difficult to determine as they increase. Ideally, I would like Mathematica to automatically generate some representation of the matrix that will highlight its structure. For instance,

(A = {{1, 2 + 3 I}, {2 - 3 I, 4}}) // StructureForm 

will give

 {{a, b}, {Conjugate[b], c}} 

or even

 {{a, b + c I}, {b - c I, d}} 

is acceptable. Somewhat naive implementation

 StructureForm[M_?MatrixQ] := MatrixForm @ Module[ {pos, chars}, pos = Reap[ Map[Sow[Position[M, #1], #1] &, M, {2}], _, Union[Flatten[#2, 1]] & ][[2]]; (* establishes equality relationship *) chars = CharacterRange["a", "z"][[;; Length @ pos ]]; SparseArray[Flatten[Thread /@ Thread[pos -> chars] ], Dimensions[M]] ] 

only works for real number matrices, e.g.

 StructureForm @ {{1, 2}, {2, 3}} == {{a, b}, {b, c}} 

Obviously, I need to determine what relationships, in my opinion, can exist (equality, negation, conjugation, negative conjugation, etc.), but I'm not sure how to establish that these relations exist, at least in pure form. And, as soon as I have a relationship, the next question is how to determine which is the simplest, in a sense? Any thoughts?

One possibility that comes to mind is that each pair of elements generates a triple linking their positions, for example, {{1,2}, Conjugate, {2,1}} for A , above, then it becomes suitable for graphic algorithms.

Change By the way, my inspiration from the Matrix Algorithms ( 1 , 2 ) series is by Stuart.

+4
source share
2 answers

We can start by identifying the relationships we want to recognize:

 ClearAll@relationship relationship[a_ -> sA_, b_ -> sB_] /; b == a := b -> sA relationship[a_ -> sA_, b_ -> sB_] /; b == -a := b -> -sA relationship[a_ -> sA_, b_ -> sB_] /; b == Conjugate[a] := b -> SuperStar[sA] relationship[a_ -> sA_, b_ -> sB_] /; b == -Conjugate[a] := b -> -SuperStar[sA] relationship[_, _] := Sequence[] 

The form in which these expressions are expressed is convenient for defining structureForm :

 ClearAll@structureForm structureForm[matrix_?MatrixQ] := Module[{values, rules, pairs, inferences} , values = matrix // Flatten // DeleteDuplicates ; rules = Thread[Rule[values, CharacterRange["a", "z"][[;; Length@values ]]]] ; pairs = rules[[#]]& /@ Select[Tuples[Range[ Length@values ], 2], #[[1]] < #[[2]]&] ; inferences = relationship @@@ pairs ; matrix /. inferences ~Join~ rules ] 

In a nutshell, this function checks every possible pair of values ​​in the matrix, writing out a substitution rule whenever the pair corresponds to a certain dependence. Note how relationship definitions are expressed in pairs of lookup rules in the form value β†’ name. Matrix values ​​are assigned the names of the letters, coming from left to right, from top to bottom. Excessive prospective relationships are ignored, subject to priority in the same order.

Beware that the function will be exhausted from the names after it finds 26 different values. If this is a problem, an alternative naming strategy is required. In addition, names are displayed as strings instead of characters. This conveniently avoids any unwanted bindings of single-letter character names. If characters are preferred, it would be trivial to apply the Symbol function to each name.

Here are some examples of using the function:

 In[31]:= structureForm @ {{1, 2 + 3 I}, {2 - 3 I, 4}} Out[31]= {{"a", "b"}, {SuperStar["b"], "d"}} In[32]:= $m = a + b I /. a | b :> RandomInteger[{-2, 2}, {10, 10}]; $m // MatrixForm $m // structureForm // MatrixForm 

enter image description here

+4
source

Have you tried looking at your own meanings? Eigenvalues ​​reveal significant information about the structure and symmetry of matrices and are standard in the statistical analysis of data sets. For instance,

  • Hermitian / symmetric eigenvalues ​​have real eigenvalues.
  • Positive semidefinite matrices have non-negative eigenvalues ​​and vice versa.
  • Rotation matrices have complex eigenvalues.
  • The circulation matrices have eigenvalues ​​that are simply the DFT of the first row . The beauty of circulant matrices is that each circulant matrix has the same set of eigenvectors. In some cases, these results (circulants) can be expanded to greenhouse matrices.

If you are dealing with matrices that are random (an experimental observation can be modeled as a random matrix), you can also read a random matrix theory that relates the distributions of eigenvalues ​​to the underlying symmetries in the matrix and the statistical distributions of the elements. In particular,

  • The distribution of the eigenvalues ​​of the symmetric / Hermitian Gaussian matrices is [semicircle]
  • The distribution of eigenvalues ​​of the Wishart matrices (if A is a random Gaussian matrix, W=AA' is the Wishart matrix) are given by the expression Marzenko-Pastur

In addition, differences (distances) between the eigenvalues ​​also transmit information about the matrix.

I'm not sure if the structure you are looking for looks like a connected graph inside a matrix or something similar ... I assume a random matrix theory (which is more general and extensive than these links will ever tell you) has some results in this respect.

This may not be exactly what you were looking for, but afaik, there is no solution to get the matrix structure. You will have to use several tools to nail it, and if I did, eigenvalues ​​would be my first choice.

+3
source

Source: https://habr.com/ru/post/1346253/


All Articles