running_covariance
running_covariance(x, state=None)Streaming covariance and correlation matrix.
Accumulates a running mean vector and covariance matrix over one or more chunks of multivariate data, mirroring the C# RunningCovarianceMatrix class. The accumulator state travels in the return value, so a chunked run holds no C++ state.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| x | array_like | A 2D array, observations in rows and variables in columns. | required |
| state | RunningCovariance | A :class:RunningCovariance from a previous call, or None (the default) to start a fresh accumulator. |
None |
Returns
| Name | Type | Description |
|---|---|---|
| RunningCovariance |
Examples
>>> from corehydropy import running_covariance
>>> x = [[1, 2], [2, 4], [3, 5], [4, 4], [5, 5]]
>>> running_covariance(x).n
5.0