[3.14] Randomize List Elements - Texas Instruments TI-89 Tip List

Graphing calculator
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

which returns
As an example of a singular matrix, find the adjoint of
with
adjoint([[1,2,3][0,1,2][0,0,0]])
which returns
(Credit to Mike Roberts for pointing out equation [2])

[3.14] Randomize list elements

Some simulations require a list of random integers, in which each integer appears only once. This
program creates such a list:
randlist(n1,n2)
Prgm
©Create list 'm' of sequential integers in random order, from n1 to n2
©Idea by David Lloyd
local n
seq(k,k,n1,n2)→m
seq(rand(),k,1,dim(m))→n
sorta n,m
EndPrgm
n1 and n2 are the starting and ending values for the list elements. The resulting list is stored in the list
m. For example, the call
randlist(0,4)
might return this for m:
{4, 2, 0, 1, 3}
The first seq() function creates a list of sequential integers from n1 to n2. The second seq() function
creates list of random integers from 1 to the size of m. The sorta command sorts both lists, using the
random list as the key, so that when the random list is sorted, the sequential list elements are
randomized.
Ideally, this program would be written as a function to return the randomized list. Unfortunately, sorta is
a command, not a function, and cannot be used in functions. The sorta arguments must be global
−7 6 −1
0 −1
1
1 −2 1
0 0 1
0 0 −2
0 0 1
1 2 3
0 1 2
0 0 0
3 - 9

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents