相関係数を指定してベ​クトルを作成する方法​はありますか?

既知の相関係数 rho と ベクトル X から新たなベクトル Y を得る方法を教えてください。

 Risposta accettata

MathWorks Support Team
MathWorks Support Team il 29 Nov 2012

0 voti

直接的な関数はございません。下記のように実現することができます。
function b = wantcorrelation(a,rho)
%WANTCORRELATION Get a vector having specified correlation with another
if abs(rho)==1
b = sign(rho) * a;
return
end
% Standardize a
a = a(:);
n = numel(a);
a = (a - mean(a)) ./ std(a);
% Get standardized noise
z = randn(size(a));
z = (z - mean(z)) ./ std(z);
% Remove any random correlation and re-standardize
r = (a'*z) / (n-1);
z = z - r*a;
z = (z - mean(z)) ./ std(z);
% Create new variable with desired correlation
lambda = rho / sqrt(1-rho^2);
b = z + lambda*a;

Più risposte (0)

Categorie

Scopri di più su Deep Learning Toolbox in Centro assistenza e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!