cmatrix.Matrix.gap

Matrix.gap()

Compute the absolute gap between self matrix and given mat. Can be used to compare probabilities matrix.

Parameters

Type

Description

mat

Matrix

The matrix to gap with self

mode

int

Get the absolute or relative gap
  • 0 mean absolute

  • 1 mean relative

Returns
Matrix

The absolute gap matrix between self matrix and mat.

Examples

>>> m=rand(3)
>>> n=rand(3)
>>> print(m)
| +9.000 | +3.000 | +8.000 |
| +8.000 | +3.000 | +3.000 |
| +3.000 | +5.000 | +3.000 |
printed
>>> print(n)
| +7.000 | +8.000 | +6.000 |
| +4.000 | +0.000 | +2.000 |
| +3.000 | +7.000 | +6.000 |
printed
>>> print(m.gap(n,0))
| +2.000 | +5.000 | +2.000 |
| +4.000 | +3.000 | +1.000 |
| +0.000 | +2.000 | +3.000 |
printed
>>> print(m.gap(n,1))
| +0.091 | +0.227 | +0.091 |
| +0.182 | +0.136 | +0.045 |
| +0.000 | +0.091 | +0.136 |
printed