Covariance from standard deviation and correlation (covcorr)
バージョン 1.0.3 (1.49 KB) 作成者:
Gregory Pelletier
This MATLAB function converts standard deviation and the correlation matrix to a covariance matrix
This MATLAB function converts standard deviation and correlation to covariance
INPUTS:
psigma = vector of standard deviations for each of any number of variables or parameters
prho = correlation matrix of the correlations between each each variable or parameter
OUTPUTS:
pcov = covariance matrix between variables or parameters
EXAMPLE:
load hospital
X = [hospital.Weight hospital.BloodPressure];
% Find the correlation matrix for the variables X:
prho = corrcoef(X)
% prho =
% 1.0000 0.1558 0.2227
% 0.1558 1.0000 0.5118
% 0.2227 0.5118 1.0000
% Find the standard deviations of each variable X
psigma = std(X)
% psigma =
% 26.5714 6.7128 6.9325
% Find the covariance matrix between variables X:
pcov = covcorr(psigma,prho)
% pcov =
% 706.0404 27.7879 41.0202
% 27.7879 45.0622 23.8194
% 41.0202 23.8194 48.0590
引用
Gregory Pelletier (2024). Covariance from standard deviation and correlation (covcorr) (https://www.mathworks.com/matlabcentral/fileexchange/158046-covariance-from-standard-deviation-and-correlation-covcorr), MATLAB Central File Exchange. に取得済み.
MATLAB リリースの互換性
作成:
R2023b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linuxタグ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!