0

How do I create a random table of 0's and 1's with a certain density instead of a probability?

For Example:

Manipulate[Table[RandomChoice[{1 - density, density} -> {0, 1}, {10}]],
 {density, 0, 1, .01}]

There is not always a 50% density of 0's to 1's.

kglr
  • 394,356
  • 18
  • 477
  • 896
Schwarz
  • 363
  • 1
  • 8
  • 1
    RandomSample[Join[ConstantArray[0, 5], ConstantArray[1, 5]]] – Bob Hanlon Jul 22 '14 at 03:39
  • @Mr.Wizard♦ Was this asked before? Where? I'd like to be able to look at the answers. – Schwarz Jul 22 '14 at 04:43
  • 1
    @Schwarz Click the link above for "Specifying an array..." – Michael E2 Jul 22 '14 at 05:08
  • @Schwarz As Michael said, the link to the original is inserted in the gray box above your question. You are not the first to ask that either. Do you have a suggestion for how that might be made more evident? (A matter of the design of Stack Exchange sites.) – Mr.Wizard Jul 22 '14 at 05:34

0 Answers0