Ask Your Question
1

Generating random vectors list which are linearly independent

asked 3 years ago

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
Preview: (hide)

Comments

1

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

Max Alekseyev gravatar imageMax Alekseyev ( 3 years ago )

3 Answers

Sort by » oldest newest most voted
3

answered 3 years ago

Max Alekseyev gravatar image

updated 3 years ago

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()
Preview: (hide)
link
2

answered 3 years ago

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)
....:
Preview: (hide)
link
0

answered 3 years ago

osi gravatar image

thank you for all answers,I totally understand

Preview: (hide)
link

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: 3 years ago

Seen: 574 times

Last updated: Jan 30 '22