Ask Your Question

Generating random vectors list which are linearly independent

asked 2022-01-28 21:40:41 +0200

osi gravatar image

How can I get n(maybe 10) vectors that are linearly independent from a vector space?

basis=[gen.random_element() for i in range(10)]
print(gen.linear_dependence(basis)==[]) #False
edit retag flag offensive close merge delete



You cannot get 10 linearly independent vectors in a 9-dimensional vector space.

Max Alekseyev gravatar imageMax Alekseyev ( 2022-01-29 00:51:22 +0200 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2022-01-29 03:24:50 +0200

Max Alekseyev gravatar image

updated 2022-01-29 03:27:52 +0200

You can get up to 9 linearly independent vectors from a 9-dimensional space. This gives 9 vectors over GF(29), if you need less - just pick a subset of them:

Matrix( SL(9, GF(29)).random_element() ).rows()
edit flag offensive delete link more

answered 2022-01-29 18:39:26 +0200

Another approach, maybe more along the lines you were thinking:

sage: gen=VectorSpace(GF(29),9)
sage: basis = []
sage: while len(basis) < gen.dimension():
....:     v = gen.random_element()
....:     if not gen.linear_dependence(basis + [v]):
....:         basis.append(v)
edit flag offensive delete link more

answered 2022-01-30 13:40:40 +0200

osi gravatar image

thank you for all answers,I totally understand

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2022-01-28 21:37:09 +0200

Seen: 379 times

Last updated: Jan 30 '22