Message Boards Message Boards


Random Interger

Posted 9 years ago
1 Reply
4 Total Likes
Hi I am trying to create a random list of only -1 and 1.  I am only need 10 digits, I don't want any zeroes.  I have tried to use mathematica to omit 0's with the if command but that doesn't work.

H =  Table[RandomInteger [{-1}, {1}], {i, 0, 10}]
POSTED BY: Sandra Deckel
Here are a couple of approaches

RandomChoice[{-1, 1}, 10]

2 (RandomInteger[{0, 1}, 10] - 1/2)
POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract