Group Abstract Group Abstract

Message Boards Message Boards

0
|
4K Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

Generate matrix with certain conditions?

Posted 7 years ago

I want to generate a n×n matrix.

  1. I want the diagonal entries to be all 0
  2. I want a random choice of matrix elements with 0 or 1. The probability of having a 1 as a matrix element is 1/m1/m and the probability of having a 0 as a matrix element is 1?1/m1?1/m.

How to generate a command like this? Thank you!

POSTED BY: Helen Walker
3 Replies

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

Please next time link your post to the duplicated one from MSE site.

POSTED BY: EDITORIAL BOARD

What do you mean by 1?1/m1?1/m ? Even if interpreted as (1?1/m)(1?1/m) your probabilities don't add up to 1. Is this your intention?

If you chose n^2/m^2 ones and and put them into your matrix at randomly chosen off-diagonal positions the probability of finding a one should be 1/m^2. In this case you should arrive at n^2 - n^2/m^2 zeros, the probability of which is then 1 - 1/m^2.

POSTED BY: Hans Dolhaine
Posted 7 years ago

Same question posted here with a different user name.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard