Hi,
I have defined my input data set as
read {i in 1..npts, j in 1..nparams}P[i, j]<mydata.txt;
For example, my text file look like
8 |
9 |
10 |
12 |
6 |
8 |
7 |
10 |
7 |
8 |
5 |
7 |
11 |
5 |
4 |
3 |
I defined the following parameters in my model.
param npts := 4;
param jthpt;
param nparams := 4;
Now I need to use normalized value for these input dataset. I have one constraints like :
subject to constraint11n : v[1] = (P[jthpt,2] - mean of 2nd column of above table)/standard deviation of 2nd column of above table ;
Is there any way to calculate mean and standard deviation in AMPL from a given data set? If so how to express it in AMPL?
Thanks in advance.
I have added another parameter which is basically normalized value of second column.
param Q {i in 1..npts} = (P[i,2] – mean2nd) / std2nd;
Q is a 4*1 matrix.
Now, instead of using data from table P, I would like to use Q data in a constraint.
For example, previously it was
Subject to constraint 12n : v[2]= P[jthpt, 2];
Is it possible to define this constraint where my input data will be Q matrix?
param npts := 4;
param jthpt;
param nparams := 4;
param mean2nd = sum {i in 1..npts} P[i,2] / npts;
param
stdev2nd = sqrt(sum {i in 1..npts} (P[i,2]-mean2nd)^2 / npts);
Thanks in advance.