Hi guys, I have two randomly generated variables and want to generate the third which is correlated with one of them and uncorrelated with the other. How can I generate such random variable?

4 ビュー (過去 30 日間)
To be specific I have these series
e~N(0,1)and x~N(0,v), where v is variance of x
and I want to generate another variable say Y that satisfy the following conditions
E(y,e) equal to zero E(Y,x) not equal to zero
Please help me out with this.
  3 件のコメント
Solomon Gofere
Solomon Gofere 2014 年 11 月 2 日
Sorry I was not clear with my question. My notations are like this: E(x,y) refers to correlation between the two. Y and y are exactly the same, i just missed to hit shift. And e and x are correlated.
Thanks
Harry
Harry 2014 年 11 月 2 日
That's good - the answer I wrote should work for you. Please accept it if you are happy with it.

サインインしてコメントする。

採用された回答

Harry
Harry 2014 年 11 月 2 日
編集済み: Harry 2014 年 11 月 2 日
With problems like this, I always think it is easiest to start with zero-mean, unit-power uncorrelated random variables. It's difficult to write equations in this forum, so I wrote some which I have uploaded as an image at the end of this post. I assume you want real numbers, but this is straightforward to extend to the complex case.
First, here's the Matlab code:
close all; clear all; clc;
% Draw N random values for e
N = 10000;
e = randn(N,1);
% Set required variances and cross-correlation for x and y
Px = 1;
Py = 3;
rho_xy = 0.4;
% Generate s1 and s2 of length N
s1 = randn(N,1);
s2 = randn(N,1);
% Make x
x = sqrt(Px)*s1;
% Make y
B = rho_xy*sqrt(Py);
C = sqrt(Py*(1 - rho_xy^2));
y = B*x + C*s2;
% Check results
sample_Pe = mean(e.^2)
sample_Px = mean(x.^2)
sample_Py = mean(y.^2)
sample_rho_ey = e.'*y/(norm(e)*norm(y))
sample_rho_xy = x.'*y/(norm(x)*norm(y))
And here are the equations:

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by