# Make a random vector or list: randvector

### 8.3.15 Make a random vector or list: randvector

The randvector command creates random vectors (see also Section 5.27.28).

- randvector takes one mandatory argument and one optional argument:
  - n, an integer.
  - Optionally, X, which can be an integer or a random variable. In place of a random variable, the specifications for a distribution can be used. (See Section 8.3.14 for random variables and their specifications.)
- randvector(n,X) returns a vector of size n containing random integers:
  - with no second argument, distributed uniformly between -99 and +99.
  - with a second argument of X, distributed uniformly between 0 and k−1.
  - with a second argument the specification of a distribution, distributed according to this distribution.

#### Examples.

- Input:
  randvector(3)
  Output (for example):

  ⎡ ⎣ | −64,−30,70 | ⎤ ⎦

- Input:
  randvector(3,5)
  or:
  randvector(3,’rand(5)’)
  Output (for example):

  ⎡ ⎣ | 2,4,2 | ⎤ ⎦

- Input:
  randvector(3,’randnorm(0,1)’)
  Output:

  ⎡ ⎣ | −0.361127118455,−0.018325111754,1.11875485898 | ⎤ ⎦

- Input:
  randvector(3,2..4)
  Output:

  ⎡ ⎣ | 3.18034843914,2.48592940345,2.57507958449 | ⎤ ⎦