Shape similarity¶
A small general helper for comparing vectors, ignoring sign and scale. Written with mode shapes in mind — where it is known as the Modal Assurance Criterion — but it is just a squared normalised inner product and assumes nothing about the domain.
mac ¶
Squared normalised inner product of two vectors.
.. math::
\mathrm{MAC}(a, b) = \frac{|a^H b|^2}{(a^H a)(b^H b)}
1.0 when the two are parallel, 0.0 when orthogonal. Squaring the numerator is what makes the result invariant to both sign and scale, which matters because an eigensolver's choice of sign and normalisation is arbitrary.
Complex input is handled with the conjugate inner product, so complex mode shapes - from non-proportional damping, or from operational modal analysis - give the right answer rather than silently losing their imaginary part.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
array - like
|
Vectors of the same length. Real or complex. |
required |
b
|
array - like
|
Vectors of the same length. Real or complex. |
required |
Returns:
| Type | Description |
|---|---|
float
|
In [0, 1]. Returns 0.0 if either vector is zero. |
Examples:
>>> import numpy as np
>>> v = np.array([1.0, 2.0, 3.0])
>>> mac(v, v)
1.0
>>> bool(np.isclose(mac(v, -2.5 * v), 1.0)) # sign and scale invariant
True
Source code in mcmckit/core/similarity.py
mac_matrix ¶
All pairwise :func:mac values between two sets of column vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shapes_a
|
(array - like, shape(n, n_a))
|
Column vectors. A 1-D input is treated as a single column. |
required |
shapes_b
|
(array - like, shape(n, n_b))
|
|
required |
Returns:
| Type | Description |
|---|---|
(ndarray, shape(n_a, n_b))
|
|
Examples: