Statistical programming, matrix languages, and more

How do I compute sum difference of rows

Reply
Super Contributor
Posts: 292

How do I compute sum difference of rows

S(t)     X_i

.91        1

.85        2

.76       3

.61       4

.55      5

How to I compute this from data above.?

Z=(0.91-0.85)(2-1)  +  (0.91-0.76)(3-1) + (0.91-0.61)(4-1) + (0.91-0.55)(5-1)

Rick gave me this solution that works well in case the difference is constant.

proc iml;
S = T(do(0.9, 0.5, -0.1));
X = T(1:5);
t = 1;  /* special reference point */

dS = S - S;
dX = X - X;
sum = dS` * dX;
print sum;

However in simulation setting it won’t work since I do not know the values of S(t) and X_i. So I am looking for a general code.

For Example how do I used the code above for this case that I simulate;

Data test;

Do i=1 to 100;

S(t)=ranexp(0)/3;

X_i= ranexp(0)/2;

Output;

End;

Thanks

Ask a Question
Discussion stats
  • 0 replies
  • 234 views
  • 0 likes
  • 1 in conversation