## creation of vectors from normal distribution

Problems with syntax of GAMS
chidia
User Posts: 5
Joined: 4 months ago

### creation of vectors from normal distribution

Untitled_1.gms
Hello,
I have a problem programming a CCR model with inputs and outputs. I need to extract the values to be used as input and output from a normal distribution. For this, I thought of creating two vectors of random variables (a and b) by extracting the values (through the normal function) from a normal distribution with mean and standard deviation which are inserted in two different tables. With the current setting (which you find in the attachment) the software gives me error 149.

Renger
Posts: 566
Joined: 3 years ago

### Re: creation of vectors from normal distribution

Hi
You could search in this forum for Error 149 as strongly advised in the "Forum rules"...

Code: Select all

`````` 115  parameter a(i,j);
116  a(i,j)= normal(x(j,i),t(j,p));
``````
or study the error message "149 Uncontrolled set entered as constant".

You define a parameter over the sets i and j, but on the right-hand side you use another set (p). Either your parameter is defined over all three sets, or you do something with the set p on the RHS (e.g. sum(p, .....)).

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

chidia
User Posts: 5
Joined: 4 months ago

### Re: creation of vectors from normal distribution

Hi Renger!
Thank you for your answer. I tried to add the index "p" to the vector a (i, j), becoming a (i, j, p) but I don't get what I want.

Code: Select all

``````parameter a(i,j,p);
a(i,j,p)= normal(x(j,i),t(j,p));

parameter b(r,j,q);
b(r,j,q)= normal(y(j,r),z(j,q));``````
In fact, in the results (you find a screen in the attachments) I get 3 values ​​of "p" for each "i" and for each "j".

I have to get a value extracted from the normal distribution for each "i" and for each "j" but the mean and standard deviation are inserted in two different tables.
I don't find how the "sum" function can help.
Thanks so much

Diana

Renger
Posts: 566
Joined: 3 years ago

### Re: creation of vectors from normal distribution

Hi Diana
If I understand you correctly, the table t contains several variables and you want to use the mean of these values for j.
You can then just sum over p and divide by the rank of p (which gives you the number of elements of p):

Code: Select all

``````a(i,j)= normal(x(j,i),sum(p,t(j,p))/rank(p));
``````
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist