To simulate Bivariate Normal samples? Easy.
- From: "\"Luis A. Afonso\"" <licas_@xxxxxxxxxxx>
- Date: Thu, 05 Jan 2006 19:26:35 EST
I remembered from my notes and from
http://www.statisticalengineering.com
/bivariate_normal.htm
the *recipe* to simulate a bivariate
normal pair X, Y:
(this mail answers to a hypothetical consult)
This distribution has 5 parameters,
namely: muX, muY, sdX, sdY, ro.
The algorithm is
____X = muX + sdX * Z1
____Y = muY +
_____+ sdY*(Z1*ro + Z2* sqrt(1-ro*ro))
where Z1 and Z2 is a pair
of independent values of N(0, 1)
, i. e., normal standard.
Note : the routine below the parameters
notation had changed.
REM "BIN"
2 CLS
PRINT " PRODUCING “
PRINT “ BIVARIATE-NORMAL samples "
INPUT " X , mean , sd "; xm, xsd
INPUT " Y , mean , sd "; ym, ysd
INPUT " Correlation Coeff. "; cc
IF xsd <= 0 OR ysd <= 0 THEN GOTO 2
IF ABS(clc) > 1 THEN GOTO 2
RANDOMIZE TIMER
pi = 4 * ATN(1)
5 a = SQR(-2 * LOG(RND)): r = RND
Z1 = a * COS(2 * pi * r)
Z2 = a * SIN(2 * pi * r)
x = xm + xsd * Z1
b = Z1 * cc + Z2 * SQR(1 - cc * cc)
y = ym + ysd * b
PRINT x, y
END
____________licas ( Luis Amaral Afonso)
.
- Prev by Date: Re: Rich Ulrich continues his statistical Muddle, Quackery, and MALPRACTICE
- Next by Date: A little problem
- Previous by thread: Re: Rich Ulrich continues his statistical Muddle, Quackery, and MALPRACTICE
- Next by thread: A little problem
- Index(es):
Loading