cvar.m
来自「一个非常实用的统计工具箱」· M 代码 · 共 37 行
M
37 行
function c = cvar(x,y,z)%CVAR Covariance.%% c = cvar(x,y)%% The covariance is computed between all columns in x and % all columns in y. If only one argument x is given then % the covariance matrix for x is returned instead, i e% the result is the same as for the call cvar(x,x).%% See also CORR, SPEARMAN.% GPL Copyright (c) Anders Holtsberg, 1998, 1999if nargin < 2 if size(x,1) == 1 x = x'; end n = size(x,1); m = mean(x); x = x-m(ones(n,1),:); c = (x'*x)/(n-1);else if size(x,1) == 1 x = x'; end if size(y,1) == 1 y = y'; end n = size(x,1); mx = mean(x); my = mean(y); x = x-mx(ones(n,1),:); y = y-my(ones(n,1),:); c = (x'*y)/(n-1); end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?