I have found very little help about the Generate command of the RandomTools package.

I also have minor gripes about the syntax. And what better way to deal with these than to voice them?

This is how I was able to generate random lists and random Matrices.

A list of 10 random integers between 1 and 100:

L := RandomTools:-Generate(list(integer(range=1..100),10));

      L := [47, 8, 46, 44, 9, 77, 59, 16, 1, 70]

 

A 3x3 Matrix of random integers between 1 and 100:
M := Matrix(3,3,RandomTools:-Generate(integer(range=1..100),makeproc=true));

      M := Matrix(3, 3, {(1, 1) = 45, (1, 2) = 96, (1, 3) = 6, (2, 1) = 98, (2, 2) = 59, (2, 3) = 44, (3, 1) = 100, (3, 2) = 38, (3, 3) = 69})

First, the syntax appears to be different for lists and Matrices. Having learned how to create a random list I expected to be able to do something like: 

RandomTools:-Generate(Matrix(integer(range=1..100),3,3)); # incorrect

or:

list(3,RandomTools:-Generate(integer(range=1..100),makeproc=true)); # incorrect

I think it would be useful to have a unified syntax. 

Secondly, I have not found much in the way of help about the 'makeproc' option. I think a natural first attempt at generating a Matrix of random integers is:

M := Matrix(3,3,RandomTools:-Generate(integer(range=1..100))); # incorrect

but this fills the Matrix with the same random integer in every cell.

What does 'makeproc' do? and why doesn't the default assume "makeproc= true"?

Thirdly,  the random integers are presumably drawn from a uniform distribution, but I was unable to make the 'method' option work with integers. Consider:

L := RandomTools:-Generate(list(integer(range=1..100,method=uniform),10)): # incorrect
Error, (in RandomTools:-Generate) invalid input: too many and/or wrong type of arguments passed to unknown; first unused argument is method = uniform

L := RandomTools:-Generate(list(float(range=1..100,method=uniform),10)): # works

 

 

Conclusion: There is not enough documentation (that I could find) on RandomTools:-Generate, and the syntax appears to have inconsistencies.

Please feel free to comment.


Please Wait...