Generating a random variable that has a predefined covariance with other random variable
이전 댓글 표시
I wanted to generate a normal random variable which has a predefined co-variance with another random number. But I can't figure out how to proceed.Here is the specific problem,
I have e~N(0,1) and I want to generate X such that cov(x,e)=1 and E(X)=0. How can I generate this random number with sample size 500?
Thanks!
채택된 답변
추가 답변 (2개)
How about just setting X=e ?
댓글 수: 3
John D'Errico
2014년 11월 1일
Except the question was about the covariance. If the correlation was to be 1, then X=e would be correct.
Roger Stafford
2014년 11월 1일
Setting X = e does give a covariance of 1, because e was stated as N(0,1).
John D'Errico
2014년 11월 1일
Oops, yes. I missed that.
the cyclist
2014년 11월 1일
편집: the cyclist
2014년 11월 1일
0 개 추천
If you have the Statistics Toolbox, you can use the mvnrnd command.
If you don't, you can use Cholesky decomposition to do this. This page seems to have a pretty good explanation, and there is even some MATLAB code there.
카테고리
도움말 센터 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!