# \[AMPL 25055\] Warning: variable argument to random function Normal (simulation based optimization)

**URL:** <https://discuss.ampl.com/t/ampl-25055-warning-variable-argument-to-random-function-normal-simulation-based-optimization/1216>\
**Category:** Google Group Mirror\
**Created:** [September 20, 2024, 4:00pm UTC](https://discuss.ampl.com/t/ampl-25055-warning-variable-argument-to-random-function-normal-simulation-based-optimization/1216 "2024-09-20T16:00:39Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [September 23, 2024, 5:08pm UTC](https://discuss.ampl.com/t/ampl-25055-warning-variable-argument-to-random-function-normal-simulation-based-optimization/1216/2 "2024-09-23T17:08:22Z")

</div>

The AMPL function Normal(mean,var) returns a pseudo-random sample from the normal distribution with specified mean and variance. Called repeatedly, it returns a different value each time:

```auto
ampl: print Normal(0,3.5);
-1.8547285751205824
ampl: print Normal(0,3.5);
5.316445484560852
ampl: print Normal(0,3.5);
-2.078602454572513

```

Normal can be called from AMPL to generate random data for a model, but it is not accessible to solvers. Thus models that apply Normal to decision variables are rejected:

```auto
ampl: option solver knitro;
ampl: solve;
Error executing "solve" command:
error processing constraint Random_State[1]:
	can't evaluate Normal
	(random function of variable argument).

```

If you only want to assign random _initial_ values to the state\_y variables, based on some initial value of theta\_y, that is possible:

```auto
var theta_y >= 0.00001;
var state_y {SIM};
.......
let theta_y := 0.5;
let {j in SIM} state_y[j] := Normal(0, theta_y);
.......
solve;

```

Also, it is possible to use a variable as an argument to a Normal _distribution_ function in a model. Several forms of the normal distribution function are available from AMPL’s [extended function library](https://ampl.com/products/ampl/extended-function-library/).

---

_[View the full topic](https://discuss.ampl.com/t/ampl-25055-warning-variable-argument-to-random-function-normal-simulation-based-optimization/1216)._
