ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 09 Mar 2020 18:56:08 +0100Unimodular matrices with additional restrictionshttps://ask.sagemath.org/question/50203/unimodular-matrices-with-additional-restrictions/I'd like to generate some unimodular matrices over ZZ with some restrictions:
1. the entries are between -2 and 2
2. the matrix is symmetric: $A = A^t$
Item (1) above can be addressed with the option `upper_bound`. Simply searching for matrices satisfying (1) and (2),
for j in [1..1000]:
A = random_matrix(ZZ,3,3, algorithm = 'unimodular', upper_bound = 3, max_tries = 1000)
if A == A.transpose():
A
becomes extremely inefficient, especially as the dimension grows.
Is there a way to enforce items (1),(2) within the unimodular algorithm? Or another workaround?
Edit: I originally also wanted the diagonal entries fixed at 2, but this is a bit too restrictive.Daniel LMon, 09 Mar 2020 18:56:08 +0100https://ask.sagemath.org/question/50203/Generating random matricies with random_matrixhttps://ask.sagemath.org/question/42275/generating-random-matricies-with-random_matrix/I'm having trouble finding the documentation for random_matrix what distributions are available besides the uniform distribution and what is the range of the uniform distribution?
Sorry if this is obvious but I'm having trouble finding this info in the doc.sagemath.org standardtrickynessMon, 07 May 2018 03:31:11 +0200https://ask.sagemath.org/question/42275/Generating a random vector with elements in specified rangehttps://ask.sagemath.org/question/42168/generating-a-random-vector-with-elements-in-specified-range/ I would like to generate a random vector in which its elements are between 0 and 1 (including 0 and 1). As far as I know,
`v = random_matrix(ZZ, 1, 10)` is a way to generate a random matrix. How would I restrict the elements to the range I want?
I am trying to build a function with a probability input, and then compare the probability to each of the elements separately in the random vector.
ds22Wed, 25 Apr 2018 20:53:28 +0200https://ask.sagemath.org/question/42168/random matrix with determinant +- 1https://ask.sagemath.org/question/40912/random-matrix-with-determinant-1/ I want to generate a random 4x4 matrix with integer entries and determinant either 1 or -1. I know that you can use
`random_matrix(ZZ,4,4, algorithm = 'unimodular')`
to generate matrices with determinant 1 (so in the special linear group). However, I'm actually more interested in the matrices with determinant -1.
Is there a 'Sage' way to do this? Or are there other functions/routines out there I should look at?
Thanks!
Daniel LThu, 01 Feb 2018 05:15:26 +0100https://ask.sagemath.org/question/40912/Random matrix satisfying a given polynomialhttps://ask.sagemath.org/question/39721/random-matrix-satisfying-a-given-polynomial/ If a polynomial f(x) of order n is given, can we find a random square matrix A of order m so that f(A)=0?
I tried to construct it by finding the roots of f(x) and then creating random matrix with those roots as eigenvalues. But the problem occurs when n is not equal to m. I'm unable to set the eigenvalue, dimensions suitably.Deepak SarmaWed, 22 Nov 2017 11:38:13 +0100https://ask.sagemath.org/question/39721/Random positive definite matrixhttps://ask.sagemath.org/question/39607/random-positive-definite-matrix/ How can I get a random positive definite (or positive semi definite) matrix of given order? I know that there is a inbuilt function random_matrix with an additional feature algorithm to set with it. But there we can get some special matrices like 'echelon_form', 'orthogonal' ', 'echelonizable', 'diagonalizable'.... but positive definite command is not in built there. Some other important matrix classes are not there. So how to obtain random matrix of those classes?Deepak SarmaThu, 16 Nov 2017 15:58:26 +0100https://ask.sagemath.org/question/39607/