Question on tilde operator (~) and 'le' logical comparison in GAUSS

User ForumQuestion on tilde operator (~) and 'le' logical comparison in GAUSS

proc (1) = gamesim(para,msel,nobs);
local bet1, bet2,
del1, del2,
alp, alp1, alp2,
pim1, pim2, pid1, pid2,
pm1, pm2, pd1, pd2,
yy,
i;

bet1 = para[1];
del1 = para[2];
bet2 = para[3];
if msel[1] == 1;
del2 = para[4];
elseif msel[1] == 2;
del2 = del1;
endif;
alp1 = para[5];
alp2 = para[6];
alp = alp12_to_alp(para[1:6]');

pim1 = bet1 + rndn(nobs,1);
pim2 = bet2 + rndn(nobs,1);
pid1 = pim1 - del1;
pid2 = pim2 - del2;

yy = zeros(nobs,2);

i = 1;
do until i > nobs;

pm1 = pim1[i];
pm2 = pim2[i];
pd1 = pid1[i];
pd2 = pid2[i];

if (pm1<0) AND (pm2<0); yy[i,.] = (0~0); elseif (pd1>0) AND (pd2>0); yy[i,.] = (1~1);
elseif (pm1 GE 0) AND (pm2 < 0); yy[i,.] = (1~0); elseif (pm1 < 0) AND (pm2 GE 0); yy[i,.] = (0~1); elseif (pd1 GE 0) AND (pm2 GE 0) AND (pd2 < 0); yy[i,.] = (1~0); elseif (pm1 GE 0) AND (pd1 < 0) AND (pd2 GE 0); yy[i,.] = (0~1); else; if rndu(1,1) LE alp; yy[i,.] = (1~0); else; yy[i,.] = (0~1); endif; endif; i = i+1; endo; yy = yy~pim1~pim2~pid1~pid2;

retp(yy);
endp;

Can anyone explain little about the following three part?

"alp = alp12_to_alp(para[1:6]‘);"  I don't understand the logic how do we define variable alp

"if rndu(1,1) LE alp;"   why did we put LE alp after rndu(1,1)?

and the line:

yy = yy~pim1~pim2~pid1~pid2;

what does "~" means here.

aptech Staff answered 2 years ago
1. The line below means: if the 1x1 uniform random number created by rndu is less than or equal to the value of the variable alp.
if rndu(1,1) LE alp;

This line could have been written also this way:

tmp = rndu(1,1);
if tmp < alp;

2. The line below:
alp = alp12_to_alp(para[1:6]‘);

performs these steps 1) transpose the first 6 elements of para 2) Pass those 6 elements in to a user defined procedure called apl12_to_alp 3) Assign the return from this function call to alp. GAUSS always uses square brackets [] for indexing. Parentheses () are used for function calls and for separating operations i.e. (5*6)+7 vs 5*(6+7)

3. The tilde operator ~ performs horizontal concatenation in GAUSS. For example:
a = 5;
b = 2;
c = a~b;

will assign c to be equal to the row vector:

5 2

The tilde operator works for scalars, vectors and matrices

• Aptech Systems, Inc. Worldwide Headquarters

Aptech Systems, Inc.
2350 East Germann Road, Suite #21
Chandler, AZ 85286

Phone: 360.886.7100
FAX: 360.886.8922

• Training & Events

Want more guidance while learning about the full functionality of GAUSS and its capabilities? Get in touch for in-person training or browse additional references below.

• Tutorials

Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.

• Have a Specific Question?

Get a real answer from a real person

• Need Support?
• Support Plans

Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.

• User Forums

Join our community to see why our users are considered some of the most active and helpful in the industry!