Ask Your Question
1

Generating random vectors list which are linearly independent

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

osi gravatar image

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

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

Comments

1

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

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

3 Answers

Sort by ยป oldest newest most voted
0

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

osi gravatar image

thank you for all answers,I totally understand

edit flag offensive delete link more
2

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

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
3

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

Max Alekseyev gravatar image

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

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

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-01-28 21:37:09 +0100

Seen: 518 times

Last updated: Jan 30 '22