Next: crosscorr, Previous: cosh, Up: Internal Routines [Contents][Index]

`covariance(`

`x`, `y` [, `mode`, weights=`w`],
/sample, /population, /keepdims, /double, /omitnans])

By default, this function returns the sample covariance of numerical
arrays

and `x`

, which must have the same
number of elements.
`y`

If

is a scalar or an array with a size different
from that of `mode`

, then it indicates the dimension(s) along
which covariances are calculated for each combination of the remaining
coordinates. In that case, if also `x``/keepdims`

is specified,
then the dimension(s) along which the covariances are calculated are
set to 1 in the result. If `/keepdims`

is not set, then such
dimensions are omitted from the result, and if only a single number is
returned, then it is returned as a scalar.

If

is an array with the same number of elements as
`mode`

, then each element of `x`

identifies the
(scalar) class to which each corresponding element of `mode`

and `x`

belong, and then a covariance is returned for each
class. The first element of the result refers to class `y``0`

(if
no class is negative), or to the most negative class.

If

is specified, then it must be a numerical
array with the same dimensions as `weights`

and `x`

(or merely the same number of elements, if covariances are calculated
by class), and then each of its elements indicates the weight of the
corresponding elements of `y`

and `x`

, and then
weighted covariances are returned. The `y`

are
copied to a version with the same data type as `weights`

for the
internal calculations (except that the copy is kept real even if
`x`

is complex).
`x`

If `/population`

or

are specified, then
population covariances are returned. Otherwise, sample covariances
are returned.
`weights`

If `/omitnans`

is specified, then data elements and weights that
are equal to NaN are omitted from the calculations.

Complex numbers are supported.

The result has type `double`

if

or `x`

are `y``double`

or `cdouble`

, or if `/double`

was
specified. Otherwise, the result has type `float`

.

Next: crosscorr, Previous: cosh, Up: Internal Routines [Contents][Index]