random sampling matrix

17 views
Skip to first unread message

Gazi Md Daud Iqbal

unread,
Nov 29, 2015, 2:58:12 PM11/29/15
to am...@googlegroups.com

Hi,

I am trying to create err1 matrix (6*1) where first 5 entries of the matrix are random sample which follows Normal distribution with mean 0 and 5.23 standard deviation. The last element of the matrix is 0.

What I tried -

param nsample := 5;

var z1 random = Normal(0,5.23);

param x1{1..nsample} =  Sample(z1);

 

Now my question is how to create err1 matrix in ampl where 1st five elements from x1 and the last element is 0? err1 matrix will be used as parameter in another consraint.


Any help please. Thanks in advance. 



Gazi

Victor Zverovich

unread,
Nov 30, 2015, 6:45:18 PM11/30/15
to am...@googlegroups.com
Variable attribute "random" is an extensions for stochastic programming which you don't need if you only want to sample parameter values. You can sample first nsample - 1 values and set the last value to zero as follows:

  param x1{i in 1..nsample} =  if i < nsample then Normal(0,5.23);

HTH,
Victor

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages