reference)) Roy D. Yartes, and David J. Goodman, Probability and Stochastic Processes, 2nd edition, 2005, pp.135~144.
Random Samples
1) 평균과
분산을
이용하여
구하는
방법
Conveniently, MATLAB also includes the built-in function randn to generate random samples of standard normal random variables. Thus We generate Gaussian (μ,σ) random variables by stretching and shifting standard normal random variables
function x = gaussrv(mu, sigma, m) x = mu + (sigma*randn(m,1)); |
2) CDF의
역행렬을
이용하여
구하는
방법
For continuous random variables, we use following theorem to transform a uniform (0,1) random variable U into other types of random variables.
예1) X가 exponential random variable인 경우 (즉, FX(x)=1-e-x x≥0)에
대한 sample를
발생
=> Note that if u=FX(x)=1-e-x, then x=-ln(1-u).
if U is a uniform (0,1) random variable, then Y=-ln(1-U) is an exponential (λ=1) random variable.
Using rand to approximate U, we have the following MATLAB code:
function x = exponentialrv(lambda, m) |
예2) θ가 [0,pi] 범위에서 pdf가 W(θ)=0.5*sinθ인 경우
=> ori_the = acos(1-2*rand(1,N));
============================================================================
The following theorem shows how to derive various types of random variable from the transformation X=g(U) where U is a uniform (0,1) random variable.
Theorem]
Let U be a uniform (0,1) random variable.
Let F(x) denote a CDF (cumulative distribution function) with an inverse F-1(u) defined for 0<u<1.
=> The random variable X=F-1(u) has CDF FX(x)=F(x).
=========================================================================================
간단히 말해서 X의 CDF (FX(x))와 F(x)의 역행렬의 x축 값이 uniform random variable인 경우의 CDF는 같다.
=========================================================================================
The technique of theorem is particularly useful when the CDF is an easily invertible function.
Unfortunately, there are many cases, including Gaussian and Erlang random variables, when the CDF is difficult to compute much less to invert.
-------------------------------------------------------------------------------------------------------------------------------------
We use this technique with the MATLAB rand function approximating U to generate sample values of a random variable X.
'Major > Programming' 카테고리의 다른 글
[MATLAB] MinGW-W64 수동 설치 (0) | 2018.08.15 |
---|---|
Maple, Mathematica Tutorial (0) | 2010.06.25 |
[Matlab] Random number function (랜덤함수) (0) | 2010.02.10 |
효율적인 Matlab programming (0) | 2009.08.26 |
Fortran tutorial (0) | 2008.06.15 |
댓글