Generating random expressions which needs to be "gathered and sorted" Here is an example which generates a random polynomial, of degree 5, with coefficients between 0 and 6. If ex contains duplicates, then the result may also contain duplicates. Returns a list containing a random selection of n different items from the list ex.
The unnamed function in this example ignores its arguments. This can be used with matrices, to generate a matrix with non-zero entries for example. Random_ne_subset(u) returns a non-empty random subset of u. Random_subset_n(u,n) returns a random subset of u with n elements (if possible). Random_subset(u) returns a random subset of u. STACK provides the following functions for random generation of sets. For example, to create a random list use random_permutation. There are also Maxima's random functions.
#Random objects code#
Usually we need to combine rand() with some code to generate objects.įor example, if you want a matrix with integer elements in the range -5.5 you need something like A:matrix(,)-rand(matrix(,)) This might not appear to be the neatest mathematical solution, but it is probably the most reliable. It is probably much better not to use conditional statements when creating random objects.įor example, if you would like to create a random small prime number, try p : rand()
#Random objects upgrade#
(Note to site maintainers: if you upgrade your Maxima version mid-way through an academic cycle, then there is no gurantee that the random numbers will remain the same. This ensures that when a particular student returns they see the same variant of the question. STACK creates pseudo-random numbers from a definite seed. STACK provides a Maxima function rand() which can be used in the question and answer variables. STACK can generate structured random objects. STACK Documentation Documentation home | Category index | Site map Random objects