how to define a random variable in matlab code?
조회 수: 18 (최근 30일)
이전 댓글 표시
답변 (2개)
Azzi Abdelmalek
2013년 1월 11일
편집: Azzi Abdelmalek
2013년 1월 11일
x=rand
%or
v=rand(3,4)
%or
randi(10,3,4)
댓글 수: 0
Wayne King
2013년 1월 11일
편집: Wayne King
2013년 1월 11일
That depends what you mean.
Generally what you mean is that you want some way of sampling from some probability law (distribution).
In that case, you use a random number generator to generate numbers that follow a particular distribution.
For example:
Uniform distribution on [-\pi, \pi]
x = -pi +2*pi*rand(1000,1);
hist(x)
Base MATLAB has random number generators for uniform and Gaussian random variables (randn) and random integers (randi)
The Statistics Toolbox has random number generators for a large number of common distributions.
With some ingenuity, you can use the uniform random number generator to model a large set of random variables.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!