Ask Your Question
1

random element in user defined class

asked 2017-02-20 07:09:04 +0100

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 \times n$ matrices with a particular property. How can I get a random matrix in my class xyz(5).

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-02-20 07:40:17 +0100

tmonteil gravatar image

updated 2017-02-20 07:41:37 +0100

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.

edit flag offensive delete link more

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 ( 2017-03-08 08:36:03 +0100 )edit

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

tmonteil gravatar imagetmonteil ( 2017-04-11 05:24:11 +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

1 follower

Stats

Asked: 2017-02-20 07:09:04 +0100

Seen: 354 times

Last updated: Feb 20 '17