Ask Your Question
1

How to pick a matrix uniformly from a certain matrix space?

asked 2022-08-24 12:59:53 +0100

Sri1729 gravatar image

Hello, I hope everyone is fine. I have a small question. Suppose M denotes the set of all 2x2 matrices with integer entries. I know how to randomly pick an element from this space (by using the sage command .random_element().

My question is:

How can I uniformly pick a matrix from this space. I am not able to find any command for that? Kindly help.

edit retag flag offensive close merge delete

Comments

From a countable set, what would it mean to pick uniformly at random?

slelievre gravatar imageslelievre ( 2022-08-24 22:02:33 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2022-08-24 15:40:47 +0100

Sébastien gravatar image

updated 2022-08-25 11:49:15 +0100

Let's create the space M:

sage: M = MatrixSpace(ZZ,2,2)
sage: M
Full MatrixSpace of 2 by 2 dense matrices over Integer Ring

The default behavior is:

sage: M.random_element()
[-2  1]
[-3  0]

One may give an interval for the values:

sage: M.random_element(x=1000, y=2000)
[1308 1271]
[1451 1352]

One may increase the density of zero entries in the elements:

sage: M.random_element(x=1000, y=2000, density=.9)
[   0 1366]
[   0 1275]

One may provide a distribution, for instance the gaussian distribution with parameter sigma=x centered at zero. Below, I translate the center at 10^9:

sage: M.random_element(distribution='gaussian', x=10^9) + 10^9 * M((1,1,1,1))
[-203915342 -852236679]
[ 222400125 1463169355]

For further information and other possible inputs, read the below documentation :

sage: M.random_element?
sage: z = M.zero_matrix()
sage: z.randomize?
sage: ZZ.random_element?
edit flag offensive delete link more

Comments

Thank you for your response. I understand your answer, but Gaussian distribution is not what I require. I am working in Lattice based cryptography and I need some method to pick elements from the matrix space under the "uniform" distribution.

Sri1729 gravatar imageSri1729 ( 2022-08-27 11:59:20 +0100 )edit

As @slelievre said, there is no such thing as uniform distribution for integer matrices, which form an infinite countable set. If the probability of every such matrix is the same, since there are infinitely such matrices, and the total probability is 1, the common probability of every single matrix should be zero. But since there are countably integer matrices, then the total probability is 0 (because the measure is sigma-additive), not 1.

tmonteil gravatar imagetmonteil ( 2022-08-27 14:15:18 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2022-08-24 12:59:53 +0100

Seen: 270 times

Last updated: Aug 25 '22