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 x
and y
, which must have the same
number of elements.
If mode
is a scalar or an array with a size different
from that of x
, then it indicates the dimension(s) along
which covariances are calculated for each combination of the remaining
coordinates. In that case, if also /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 mode
is an array with the same number of elements as
x
, then each element of mode
identifies the
(scalar) class to which each corresponding element of x
and y
belong, and then a covariance is returned for each
class. The first element of the result refers to class 0
(if
no class is negative), or to the most negative class.
If weights
is specified, then it must be a numerical
array with the same dimensions as x
and y
(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 x
and y
, and then
weighted covariances are returned. The weights
are
copied to a version with the same data type as x
for the
internal calculations (except that the copy is kept real even if
x
is complex).
If /population
or weights
are specified, then
population covariances are returned. Otherwise, sample covariances
are returned.
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 x
or y
are double
or cdouble
, or if /double
was
specified. Otherwise, the result has type float
.
Next: crosscorr, Previous: cosh, Up: Internal Routines [Contents][Index]