Message Boards Message Boards

0
|
2612 Views
|
1 Reply
|
4 Total Likes
View groups...
Share
Share this post:

Random Interger

Posted 10 years ago
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
Attachments
Remove
or Discard

Group Abstract Group Abstract