You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compute the Pearson covariance between the vector(s) in `v1` and `v2`. Here, `v1` and `v2` can be either vectors or matrices.
9010
-
9011
-
This function accepts three keyword arguments:
9012
-
9013
-
- `vardim`: the dimension of variables. When `vardim = 1`, variables are considered in columns while observations in rows; when `vardim = 2`, variables are in rows while observations in columns. By default, it is set to `1`.
9014
-
- `corrected`: whether to apply Bessel's correction (divide by `n-1` instead of `n`). By default, it is set to `true`.
9015
-
- `mean`: allow users to supply mean values that are known. By default, it is set to `nothing`, which indicates that the mean(s) are unknown, and the function will compute the mean. Users can use `mean=0` to indicate that the input data are centered, and hence there's no need to subtract the mean.
9016
-
9017
-
The size of the result depends on the size of `v1` and `v2`. When both `v1` and `v2` are vectors, it returns the covariance between them as a scalar. When either one is a matrix, it returns a covariance matrix of size `(n1, n2)`, where `n1` and `n2` are the numbers of slices in `v1` and `v2`, which depend on the setting of `vardim`.
9018
-
9019
-
Note: `v2` can be omitted, which indicates `v2 = v1`.
covzm(x .- xmean, y .- ymean; corrected=corrected)
287
+
Compute the variance of the vector `x`. If `corrected` is `true` (the default) then the sum is scaled with `n-1` wheares the sum is scaled with `n` if `corrected` is `false` where `n = length(x)`.
# This ugly hack is necessary to make the method below considered more specific than the deprecated method. When the old keyword version has been completely deprecated, these two methods can be merged
covzm(x .- xmean, y .- ymean; vardim=vardim, corrected=corrected)
293
+
doc"""
294
+
cov(X[, vardim=1, corrected=true])
288
295
289
-
# cov (API)
296
+
Compute the covariance matrix of the matrix `X` along the dimension `vardim`. If `corrected` is `true` (the default) then the sum is scaled with `n-1` wheares the sum is scaled with `n` if `corrected` is `false` where `n = size(X, vardim)`.
# This ugly hack is necessary to make the method below considered more specific than the deprecated method. When the old keyword version has been completely deprecated, these two methods can be merged
throw(ArgumentError("invalid value of mean, $(mean)::$(typeof(mean))"))
303
-
end
306
+
Compute the covariance between the vectors `x` and `y`. If `corrected` is `true` (the default) then the sum is scaled with `n-1` wheares the sum is scaled with `n` if `corrected` is `false` where `n = length(x) = length(y)`.
# This ugly hack is necessary to make the method below considered more specific than the deprecated method. When the old keyword version has been completely deprecated, these two methods can be merged
covm(x, _vmean(x, vardim), y, _vmean(y, vardim); vardim=vardim, corrected=corrected)
317
-
elseifisa(mean, (Any,Any))
318
-
covm(x, mean[1], y, mean[2]; vardim=vardim, corrected=corrected)
319
-
else
320
-
throw(ArgumentError("invalid value of mean, $(mean)::$(typeof(mean))"))
321
-
end
322
-
end
317
+
Compute the covariance between the vectors or matrices `X` and `Y` along the dimension `vardim`. If `corrected` is `true` (the default) then the sum is scaled with `n-1` wheares the sum is scaled with `n` if `corrected` is `false` where `n = size(X, vardim) = size(Y, vardim)`.
covm(X, _vmean(X, vardim), Y, _vmean(Y, vardim), vardim, corrected)
322
+
# This ugly hack is necessary to make the method below considered more specific than the deprecated method. When the old keyword version has been completely deprecated, these two methods can be merged
# This ugly hack is necessary to make the method below considered more specific than the deprecated method. When the old keyword version has been completely deprecated, these two methods can be merged
# This ugly hack is necessary to make the method below considered more specific than the deprecated method. When the old keyword version has been completely deprecated, these two methods can be merged
throw(ArgumentError("invalid value of mean, $(mean)::$(typeof(mean))"))
434
-
end
438
+
Compute the Pearson correlation between the vectors `x` and `y`.
439
+
"""
440
+
cor{T<:AbstractVector,S<:AbstractVector}(x::T, y::S) =corm(x, Base.mean(x), y, Base.mean(y))
441
+
# This ugly hack is necessary to make the method below considered more specific than the deprecated method. When the old keyword version has been completely deprecated, these two methods can be merged
corm(x, _vmean(x, vardim), y, _vmean(y, vardim), vardim)
451
+
# This ugly hack is necessary to make the method below considered more specific than the deprecated method. When the old keyword version has been completely deprecated, these two methods can be merged
452
+
cor(x::AbstractVecOrMat, y::AbstractVecOrMat) =
453
+
corm(x, _vmean(x, vardim), y, _vmean(y, vardim), 1)
Compute the Pearson covariance between the vector(s) in ``v1`` and ``v2``\ . Here, ``v1`` and ``v2`` can be either vectors or matrices.
1698
+
Compute the variance of the vector ``x``\ . If ``corrected`` is ``true`` (the default) then the sum is scaled with ``n-1`` wheares the sum is scaled with ``n`` if ``corrected`` is ``false`` where ``n = length(x)``\ .
1699
1699
1700
-
This function accepts three keyword arguments:
1700
+
.. function:: cov(X[, vardim=1, corrected=true])
1701
1701
1702
-
* ``vardim``\ : the dimension of variables. When ``vardim = 1``\ , variables are considered in columns while observations in rows; when ``vardim = 2``\ , variables are in rows while observations in columns. By default, it is set to ``1``\ .
1703
-
* ``corrected``\ : whether to apply Bessel's correction (divide by ``n-1`` instead of ``n``\ ). By default, it is set to ``true``\ .
1704
-
* ``mean``\ : allow users to supply mean values that are known. By default, it is set to ``nothing``\ , which indicates that the mean(s) are unknown, and the function will compute the mean. Users can use ``mean=0`` to indicate that the input data are centered, and hence there's no need to subtract the mean.
1702
+
.. Docstring generated from Julia source
1703
+
1704
+
Compute the covariance matrix of the matrix ``X`` along the dimension ``vardim``\ . If ``corrected`` is ``true`` (the default) then the sum is scaled with ``n-1`` wheares the sum is scaled with ``n`` if ``corrected`` is ``false`` where ``n = size(X, vardim)``\ .
1705
+
1706
+
.. function:: cov(x, y[, corrected=true])
1707
+
1708
+
.. Docstring generated from Julia source
1705
1709
1706
-
The size of the result depends on the size of ``v1`` and ``v2``\ . When both ``v1`` and ``v2`` are vectors, it returns the covariance between them as a scalar. When either one is a matrix, it returns a covariance matrix of size ``(n1, n2)``\ , where ``n1`` and ``n2`` are the numbers of slices in ``v1`` and ``v2``\ , which depend on the setting of ``vardim``\ .
1710
+
Compute the covariance between the vectors ``x`` and ``y``\ . If ``corrected`` is ``true`` (the default) then the sum is scaled with ``n-1`` wheares the sum is scaled with ``n`` if ``corrected`` is ``false`` where ``n = length(x) = length(y)``\ .
1707
1711
1708
-
Note: ``v2`` can be omitted, which indicates ``v2 = v1``\ .
Compute the covariance between the vectors or matrices ``X`` and ``Y`` along the dimension ``vardim``\ . If ``corrected`` is ``true`` (the default) then the sum is scaled with ``n-1`` wheares the sum is scaled with ``n`` if ``corrected`` is ``false`` where ``n = size(X, vardim) = size(Y, vardim)``\ .
1717
+
1718
+
.. function:: cor(x)
1711
1719
1712
1720
.. Docstring generated from Julia source
1713
1721
1714
-
Compute the Pearson correlation between the vector(s) in ``v1`` and ``v2``\ .
1722
+
Return the number one.
1723
+
1724
+
.. function:: cor(X[, vardim=1])
1725
+
1726
+
.. Docstring generated from Julia source
1727
+
1728
+
Compute the Pearson correlation matrix of the matrix ``X`` along the dimension ``vardim``\ .
1729
+
1730
+
.. function:: cor(x, y)
1731
+
1732
+
.. Docstring generated from Julia source
1733
+
1734
+
Compute the Pearson correlation between the vectors ``x`` and ``y``\ .
1735
+
1736
+
.. function:: cor(X, Y[, vardim=1])
1737
+
1738
+
.. Docstring generated from Julia source
1715
1739
1716
-
Users can use the keyword argument ``vardim`` to specify the variable dimension, and ``mean`` to supply pre-computed mean values.
1740
+
Compute the Pearson correlation between the vectors or matrices ``X`` and ``Y`` along the dimension ``vardim``\ .
0 commit comments