simulation of a random variable

조회 수: 6 (최근 30일)
Elena
Elena 2015년 1월 28일
댓글: Image Analyst 2015년 1월 28일
If i have a random variable Z=X+Y where X and Y are independent and continuous random variables, how can i sample/ simulate from Z using matlab?

답변 (2개)

John D'Errico
John D'Errico 2015년 1월 28일
편집: John D'Errico 2015년 1월 28일
Generate random variables X and Y independently, then add them.
I fail to see the problem here.
Assuming you know how to add, I suppose that maybe you don't know how to sample from a random variable. But since you have not told us what their distributions are, I'm not going to tell you how to sample from any possible general random variable. That would be a book to write, and not even a terribly small one.
There are tools in MATLAB to sample from random variables. The lookfor command would help you there to find them. You need to learn how to find things in MATLAB, so learn to use lookfor, and learn to use the help provided. For example, what does this do?
lookfor random
You might start with rand, a function that probably exists in almost any language.
  댓글 수: 3
John D'Errico
John D'Errico 2015년 1월 28일
Of course it is possible. But since you have not told us what the distributions of X and Y are, then how can I know?
Are you asking that this be forced? Again, the distributions matter here. If that is a requirement, then the variables X and Y may not be independent in some circumstances. Again, without knowing the distributions, nothing is known.
Are you asking how to actually find those samples which exceeded 1, then just use the function find!
Be clear about your question. I think you really need to start reading the help though. There are good tutorials to be read, and you seem to be asking very basic questions.
Image Analyst
Image Analyst 2015년 1월 28일
Elena, if you're not wanting to use the uniform or Normal distribution, you can get nearly any one you can think of here: http://www.mathworks.com/matlabcentral/fileexchange/7309-randraw

댓글을 달려면 로그인하십시오.


Star Strider
Star Strider 2015년 1월 28일
Do you want a value of Z>1? With the rand function, it is quite likely that you will get values of Z that are greater than 1, since rand produces values on the interval (0,1).
If you want to be certain that Z is always on the interval (0,1), divide the sum by 2:
Z = (X + Y)/2;

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by