dcor.mean_product¶
- mean_product(a, b)[source]¶
Average of the elements for an element-wise product of two matrices.
If the matrices are square it is
\[\frac{1}{n^2} \sum_{i,j=1}^n a_{i, j} b_{i, j}.\]- Parameters
a (T) – First input array to be multiplied.
b (T) – Second input array to be multiplied.
- Returns
Average of the product.
- Return type
T
See also
u_product
Examples
>>> import numpy as np >>> import dcor >>> a = np.array([[1, 2, 4], [1, 2, 4], [1, 2, 4]]) >>> b = np.array([[1, .5, .25], [1, .5, .25], [1, .5, .25]]) >>> dcor.mean_product(a, b) 1.0 >>> dcor.mean_product(a, a) 7.0
If the matrices involved are not square, but have the same dimensions, the average of the product is still well defined
>>> c = np.array([[1, 2], [1, 2], [1, 2]]) >>> dcor.mean_product(c, c) 2.5