Average of results replicas

Problems with syntax of GAMS
Post Reply
chidia
User
User
Posts: 5
Joined: 4 years ago

Average of results replicas

Post by chidia »

Distribuzione Beta.gms
(4.71 KiB) Downloaded 189 times

Hello,
after solving the model and applying it 4 times, I have to average the results of the 4 replicas (the results are represented by the variable z).

For each j, I have to get the average of the "z (l)". I tried this way but I get the same result for all "j's". Can someone help me? Thanks so much.

Code: Select all

Parameter mediaz(j);

mediaz(j) = sum(l0$(ord(l0)<card(l0)),z.l)/card(l0);
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Average of results replicas

Post by Renger »

Hi

Your code just sums z l0 -1 times and divides it by the number of elements in l0. You could have just written

Code: Select all

mediaz(j) = (card(l0) - 1 ) * z.l / card(l0)
You were probably looking for something like this:

Code: Select all

mediaz(j) = sum(l0$(ord(l0)<card(j)),z.l)/card(l0);
This would at least give different results.
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply