I am using older version of GAUSS 6. How do I fixed the random sample for each replication in `rndu`

generator? I use:

`replication=1000;`

`rndseed=688671;`

then `X=rndus(2,3,seed);`

end of replication.

However, for each replication loop, `X`

is different. I expect they should be exactly the same. Am I using the correct way of fixing the sample each time?

## 1 Answer

0

No, that is not correct. `rndseed`

is used to set the internal seed which is used by random number generators which do not take a seed as an input. It is not set with an equals sign. Here is a simple example:

```
// Each iteration will print the same random numbers
for i(1, 2, 1);
// No equals sign with 'rndseed'
rndseed 777;
print rndu(3, 1);
endfor;
```

If you are going to use a random number generator which accepts a seed as input, then you set this variable, not `rndseed`

, like this:

```
// Each iteration will print the same random numbers
for i(1, 2, 1);
seed = 777;
print rndus(3, 1, seed);
endfor;
```

All of those will work for older or modern versions of GAUSS. This below will also work since about GAUSS 12:

```
// Each iteration will print the same random numbers
for i(1, 2, 1);
seed = 777;
{ X, seed} = rndu(3, 1, seed);
print X;
endfor;
```

## Your Answer

## 1 Answer

No, that is not correct. `rndseed`

is used to set the internal seed which is used by random number generators which do not take a seed as an input. It is not set with an equals sign. Here is a simple example:

```
// Each iteration will print the same random numbers
for i(1, 2, 1);
// No equals sign with 'rndseed'
rndseed 777;
print rndu(3, 1);
endfor;
```

If you are going to use a random number generator which accepts a seed as input, then you set this variable, not `rndseed`

, like this:

```
// Each iteration will print the same random numbers
for i(1, 2, 1);
seed = 777;
print rndus(3, 1, seed);
endfor;
```

All of those will work for older or modern versions of GAUSS. This below will also work since about GAUSS 12:

```
// Each iteration will print the same random numbers
for i(1, 2, 1);
seed = 777;
{ X, seed} = rndu(3, 1, seed);
print X;
endfor;
```