Processing math: 100%
Ask Your Question
1

random element in user defined class

asked 8 years ago

Deepak Sarma gravatar image

Can I get random element of a user defined class of objects? For example if I define xyz(n) to generate all the n×n matrices with a particular property. How can I get a random matrix in my class xyz(5).

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 8 years ago

tmonteil gravatar image

updated 8 years ago

You have to implement a random_element method by yourself, since sage will not discover which measure has to be sampled. If the property happens frequently among all matrices, you can use rejection the method: pick a random matrix (in the larger space) until you find one with the property and return that matrix.

Preview: (hide)
link

Comments

Sorry, I don't have any idea how to implement it by myself. Can you please explain with an example? Any web link will be helpful. Thank you

Deepak Sarma gravatar imageDeepak Sarma ( 8 years ago )

It really depends on the property. Could you provide some examples of some xyz(n) that you would like to sample ?

tmonteil gravatar imagetmonteil ( 7 years ago )

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 8 years ago

Seen: 404 times

Last updated: Feb 20 '17