Using random number functions

Defining variables using random numbers is the basis of creating algorithmic variations. The basic Scientific Notebook random number function is called rand. When the insertion point is in mathematics and you type the function name, Scientific Notebook automatically recognizes the function and displays it on your screen in gray letters. (More information about using mathematical functions in Scientific Notebook is available online via the Help ContentsContents.tex.) You can combine random number functions with definitions to gain a powerful algorithmic tool.

The $\func$rand function has four forms:


An additional random number function, called randmat, produces random matrices of various types. The function has this form:


$\func$randmat$\left(\vphantom{ a,b,c,\left( d\right) }\right.$a, b, c,$\left(\vphantom{ d}\right.$d$\left.\vphantom{ d}\right)$$\left.\vphantom{ a,b,c,\left( d\right) }\right)$

where

a is the number of matrix rows,

b is the number of matrix columns,

c is the matrix type, with

        1 = arbitrary

        2 = symmetric (must be square)

        3 = antisymmetric (must be square)

        4 = unimodular and

$\left(\vphantom{ d}\right.$d$\left.\vphantom{ d}\right)$ is the selection range for the values in the matrix:

        The range (n), with n as a single positive integer, produces matrix values between 0 and n - 1.

        The range (n, m), where n < m, produces matrix values between n and m, inclusive.

        The range ({some set}) produces matrix values selected at random from the specified set.


itbpF43.125pt18.5pt4ptex3.wmfThe function $\func$randmat$\left(\vphantom{ 4,4,1,\left( 1,9\right) }\right.$4, 4, 1,$\left(\vphantom{ 1,9}\right.$1, 9$\left.\vphantom{ 1,9}\right)$$\left.\vphantom{ 4,4,1,\left( 1,9\right) }\right)$ produces a 4×4 arbitrary matrix whose values are between 1 and 9, inclusive. Here's an example:

$\func$randmat$\left(\vphantom{ 4,4,1,\left( 1,9\right) }\right.$4, 4, 1,$\left(\vphantom{ 1,9}\right.$1, 9$\left.\vphantom{ 1,9}\right)$$\left.\vphantom{ 4,4,1,\left( 1,9\right) }\right)$ = $\begin{array}{cccc}
7 & 8 & 8 & 4 \\
1 & 3 & 4 & 3 \\
4 & 4 & 8 & 9 \\
4 & 6 & 1 & 6
\end{array}$




Subsections