Page 1 of 1

### creation of vectors from normal distribution

Posted: Fri Feb 14, 2020 12:08 pm
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.

### Re: creation of vectors from normal distribution

Posted: Sat Feb 15, 2020 10:03 am
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

### Re: creation of vectors from normal distribution

Posted: Mon Feb 17, 2020 5:22 pm
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

### Re: creation of vectors from normal distribution

Posted: Tue Feb 18, 2020 8:40 am
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