RandomMatrix - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


LinearAlgebra

  

RandomMatrix

  

construct a random Matrix

  

RandomVector

  

construct a random Vector

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

RandomMatrix(r, c, den, gen, options)

RandomVector[o](d, den, gen, options)

Parameters

r

-

(optional) non-negative integer; row dimension of the resulting Matrix

c

-

(optional) non-negative integer; column dimension of the resulting Matrix

d

-

(optional) non-negative integer; dimension of the resulting Vector

den

-

(optional) equation of the form density = p where p is a numeric value with 0 <= p <= 1; probability that a generated value is assigned to an entry in the resulting Matrix or Vector

gen

-

(optional) equation of the form generator = f where f is a generator of values for the entries

[o]

-

(optional) use either [row] or [column] to specify the orientation of the resulting Vector

options

-

(optional); constructor options for the result object

Description

• 

The RandomMatrix(r, c) function returns an r x c Matrix in which all of the entries have integer values in the range -99..99.

  

If the row dimension is not provided, it defaults to 0. If the column dimension is not provided, it defaults to the row dimension.

• 

The RandomVector(d) function returns a d-dimensional Vector in which all of the entries have integer entries in the range -99..99.

  

The RandomVector[row](d) function acts like RandomVector(d), except that a row Vector is returned.  If the orientation option is omitted or if RandomVector[column](d) is used, a column Vector is returned.

  

If the dimension is not provided, it defaults to 0.

• 

The optional parameter gen can be used to define an alternate number generator. If the generator is specified as an integer or floating-point range, the appropriate rtable random initializer is used to generate the entries. This form of the generator can be used to create very large Matrices or Vectors.  This generator is very fast, but it may return different results on different platforms.  If values that are stable across platforms are required, then a stable generating procedure should be given.

  

If the optional parameter gen is given but is not a range, then it must be a procedure which takes no arguments and returns a value to be put into the constructed Matrix or Vector.

• 

The probability that an entry is assigned a value in the resulting Matrix or Vector is determined by including density = p, where 0 <= p <= 1, in the calling sequence. The placement of the random values is determined without regard to the shape (indexing function) of the Matrix or Vector; failed attempts to write a random value to a non-mutable location (as determined by the shape) are ignored.  In other words, p determines the proportion of entries in the full rectangular Matrix or Vector which the routine attempts to set to a random value, rather than the number of mutable locations which are actually set.

  

If density = p is not provided in the calling sequence, the value of p defaults to 1.

• 

The constructor options provide additional information (readonly, shape, storage, order, datatype, and attributes) to the Matrix or Vector constructor that builds the result. These options may also be provided in the form outputoptions=[...], where [...] represents a Maple list.  If a constructor option is provided in both the calling sequence directly and in an outputoptions option, the latter takes precedence (regardless of the order).

• 

This function is part of the LinearAlgebra package, and so it can be used in the form RandomMatrix(..) only after executing the command with(LinearAlgebra). However, it can always be accessed through the long form of the command by using LinearAlgebra[RandomMatrix](..).

Examples

withLinearAlgebra&colon;

RandomVector2

−3167

(1)

RandomVectorrow6&comma;generator=rand1..510

1512153102525

(2)

RandomMatrix3&comma;density=0.75&comma;generator=0..0.5

0.0.3990529283891635640.0.3198816805787657040.4905548466636499020.0.002391742250924089320.0.0941909870016631179

(3)

RandomMatrix4&comma;4&comma;generator=1..9&comma;shape=triangularlower

8000220034407299

(4)

See Also

Matrix

rand

RandomTools

type[numeric]

Vector