Re: how to generate random negative numbers

2009-08-27 Thread Boyd Stephen Smith Jr.
On Wednesday 26 August 2009 23:19:18 Celejar wrote: > On Wed, 12 Aug 2009 15:26:06 -0500 > "Boyd Stephen Smith Jr." wrote: > > $RANDOM gives a random number. It has a relatively large range, I think > > 0-32K maybe even larger. > > ... > > > Examples: > > echo $((RANDOM % 6 + 1)) # Rolls a "norma

Re: how to generate random negative numbers

2009-08-26 Thread Celejar
On Wed, 12 Aug 2009 15:26:06 -0500 "Boyd Stephen Smith Jr." wrote: ... > $RANDOM gives a random number. It has a relatively large range, I think > 0-32K maybe even larger. ... > Examples: > echo $((RANDOM % 6 + 1)) # Rolls a "normal" die[1]. ... > [1] But not a fair one. If the $RANDOM fu

Re: how to generate random negative numbers

2009-08-14 Thread Michael Pobega
On 0, Soren Orel wrote: >I know I could generate numbers like: 0; 1; 2 >with: >$[ ( $RANDOM % 3 ) + 0 ] >But how could I generate numbers like: 0; 1; 2; -1; -2; etc? So >negative+positive numbers too + zero >thank you echo $[ ($RANDOM % 5 ) -2 ] That would generate -2 th

Re: Entropy (was Re: how to generate random negative numbers)

2009-08-13 Thread Todd A. Jacobs
On Wed, Aug 12, 2009 at 04:27:09PM -0500, Ron Johnson wrote: > Does this burn through entropy faster than other methods? Probably, although since $RANDOM accesses /dev/urandom instead of /dev/random , your available entropy remains undefined in any case. As for the numerical distribution of your

Re: Entropy (was Re: how to generate random negative numbers)

2009-08-12 Thread Francois Bottin
Eric De Mund wrote: Ron, John Hasler: ] echo $(( $(( $RANDOM - $RANDOM )) % 3 )) Ron Johnson: ] Does this burn through entropy faster than other methods? Yes. Twice as fast. And, more importantly, it's mathematically incorrect. It does not have the same probability density function as: ec

Re: Entropy (was Re: how to generate random negative numbers)

2009-08-12 Thread Eric De Mund
Ron, John Hasler: ] echo $(( $(( $RANDOM - $RANDOM )) % 3 )) Ron Johnson: ] Does this burn through entropy faster than other methods? Yes. Twice as fast. And, more importantly, it's mathematically incorrect. It does not have the same probability density function as: echo $(( $(($RANDOM % 5)

Entropy (was Re: how to generate random negative numbers)

2009-08-12 Thread Ron Johnson
On 2009-08-12 16:00, John Hasler wrote: echo $(( $(( $RANDOM - $RANDOM )) % 3 )) Does this burn through entropy faster than other methods? -- Scooty Puff, Sr The Doom-Bringer -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact l

Re: how to generate random negative numbers

2009-08-12 Thread John Hasler
echo $(( $(( $RANDOM - $RANDOM )) % 3 )) -- John Hasler -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Re: how to generate random negative numbers

2009-08-12 Thread Boyd Stephen Smith Jr.
In <60f50c4a0908121232p4635c385m1d9e0d9b2d935...@mail.gmail.com>, Soren Orel wrote: >u...@debian:~$ $[ ($RANDOM % 30 ) -30 ] >bash: -26: command not found >u...@debian:~$ $[ ($RANDOM % 30 ) -30 ] >bash: -3: command not found >u...@debian:~$ $[ ($RANDOM % 30 ) -30 ] >bash: -23: command not found >u

Re: how to generate random negative numbers

2009-08-12 Thread Scott Gifford
Soren Orel writes: > u...@debian:~$ $[ ($RANDOM % 30 ) -30 ] > bash: -26: command not found [...] > it still doesn't work, and it gives only negative numbers when using e.g.: > 30-30 First, it's giving an error because it's generating a random number, then trying to run a program with that

Re: how to generate random negative numbers

2009-08-12 Thread Soren Orel
u...@debian:~$ $[ ($RANDOM % 30 ) -30 ] bash: -26: command not found u...@debian:~$ $[ ($RANDOM % 30 ) -30 ] bash: -3: command not found u...@debian:~$ $[ ($RANDOM % 30 ) -30 ] bash: -23: command not found u...@debian:~$ $[ ($RANDOM % 30 ) -30 ] bash: -2: command not found u...@debian:~$ $[ ($RANDO

Re: how to generate random negative numbers

2009-08-12 Thread Alan Chandler
Soren Orel wrote: I know I could generate numbers like: 0; 1; 2 with: $[ ( $RANDOM % 3 ) + 0 ] But how could I generate numbers like: 0; 1; 2; -1; -2; etc? So negative+positive numbers too + zero thank you $[ ($RANDOM % 5 ) -2 ] ? (I have no idea if I have the bash syntax right) -- Alan Ch