Function Repository Resource:

RandomVector

Source Notebook

Return a pseudorandom vector of a given type and size

Contributed by: Dennis M Schneider

ResourceFunction["RandomVector"][type,range,n]

returns an n-dimensional vector with entries that are random values of type type and lie in range range.

Details

The type can be Integer, Rational, Real, Complex, "GaussianInteger" or "GaussianRational".
For complex types, the range is given as a pair of complex values that are taken as diagonally opposite endpoints of a rectangle.

Examples

Basic Examples (7) 

A random three-dimensional vector whose entries are approximate real numbers between 0 and 1:

In[1]:=
ResourceFunction["RandomVector"][Real, {0, 1}, 3]
Out[1]=

A random three-dimensional vector whose entries are approximate real numbers between -5 and 10:

In[2]:=
ResourceFunction["RandomVector"][Real, {-5, 10}, 3]
Out[2]=

A random three-dimensional vector whose entries are integers between -5 and 10:

In[3]:=
ResourceFunction["RandomVector"][Integer, {-5, 10}, 3]
Out[3]=

A random three-dimensional vector whose entries are rationals between -5 and 10:

In[4]:=
ResourceFunction["RandomVector"][Rational, {-5, 10}, 3]
Out[4]=

A random three-dimensional vector whose entries are Gaussian integers between -5 and 10:

In[5]:=
ResourceFunction["RandomVector"]["GaussianInteger", {-5, 10}, 3]
Out[5]=

A random three-dimensional vector whose entries are Gaussian rationals between -5 and 10:

In[6]:=
ResourceFunction["RandomVector"]["GaussianRational", {-5, 10}, 3]
Out[6]=

A random three-dimensional vector whose entries are RandomComplex[{-5+2I,10-3I}]:

In[7]:=
ResourceFunction["RandomVector"][Complex, {-5 + 2 I, 10 - 3 I}, 3]
Out[7]=

Publisher

Dennis M Schneider

Version History

  • 1.0.0 – 20 January 2021

Related Resources

License Information