In GAMS models I often use the following simple algorithm to generate random variable:
- Generate u = Uniform(0,1)
- Solve F(x) = u
E.g. for the GAMMA distribution:
$ontext |
Using a numerical procedure is always dangerous, as we see here:
C O N O P T 3 version 3.14T Using default options. Reading Data Iter Phase Ninf Infeasibility RGmax NSB Step InItr MX OK ** An equation in the pre-triangular part of the model cannot |
The CDF of the Gamma distribution looks quite innocent:
Two simple ways of working around this. First PATH seems to handle this a little bit better (and CONOPT agrees with the solution). This can be done with:
option cns=path; solve m using cns; |
Indeed CONOPT new says:
C O N O P T 3 version 3.14T Using default options. Reading Data Iter Phase Ninf Infeasibility RGmax NSB Step InItr MX OK ** Feasible solution to a square system. |
Another solution would be to use a different starting point. We used the mean which is an obvious starting point, but with
x.l(i) = 1;
instead of
x.l(i) = m0;
CONOPT can also solve the equations directly.
This illustrates that, although we can work around things, it would be better to have a larger number of statistical functions in GAMS, including some inverse CDF’s.