random, drandm, irandm - better random number generator
function irandm (iflag)
function random (iflag)
double precision function drandm (iflag)
These functions use random(3) to generate sequences of random numbers, and should be used rather than the older functions described in man
3f rand. If iflag is non-zero, it is used as a new seed for the random number generator, and the first new random value is returned.
Irandm returns positive integers in the range 0 through 2147483647 ( 2**31-1). Random and drandm return values in the range 0. through 1.0
by dividing the integer random number from random(3) by 2147483647 .
SEE ALSO random(3)4.3 Berkeley Distribution May 15, 1985 RANDOM(3F)
Check Out this Related Man Page
rand(), rand_r(), srand() - simple random-number generator
uses a multiplicative, congruential, random-number generator with period 2^32 that returns successive pseudo-random numbers in the range
from 0 to 2^15-1.
can be called at any time to reset the random-number generator to a random starting point. The generator is initially seeded with a value
returns a random number at the address pointed to by the randval parameter. The seed parameter can be set at any time to start the random-
number generator at an arbitrary point.
The spectral properties of leave a great deal to be desired. provides a much better, though more elaborate, random-number generator (see
If seed or randval is NULL, returns 0. Otherwise, returns a psuedo-random integer.
int x, y;
x = rand();
y = rand();
would produce the same results as:
int x, y, s = 10;
Users of should note that rand_r() now conforms with POSIX.1c. The old prototype of is supported for compatibility with existing DCE
SEE ALSO drand48(3C), random(3M), thread_safety(5), random(7).
STANDARDS CONFORMANCE rand(3C)
Hi, how do I use /dev/urandom to generate a single number between 1-100? I can od /dev/urandom but it gives me an endless list of random numbers, I just want 1 between 1-100. How can I get that? Thanks. (12 Replies)
Hi one and all,
I'm working on a Bash script that is designed to calculate how much IP traffic has passed through a port to determine traffic volume over a given amount of time.
I've currently been able to use the netstat -s command coupled with grep to write to a file the total packets... (13 Replies)
I'm coding on Ubuntu 9.04 standard shell.
I'm writing a script that needs to generate a random number at some point of its execution.
When I do
echo $RANDOMas a command inside shell, I clearly get some randomly generated number
However when I do
echo $ior even... (14 Replies)
Hi, im trying to make a shell script that basically runs a random shell script form a list of shell scripts i specify. Im not very good at writing shell scripts, and am new to linux.
Thanks in advance :) (15 Replies)
I have 200 pictures in a folder and I would like move 10 random pictures every week to given folder automatically.
I have this server on 1and1.com.
So I tried the following using Bash script for manual copy and paste for testing
mapfile -t -n 3 files < <(find... (13 Replies)
Is there a tool somewhat parallel to rev, but which randomizes instead of reverses?
I've tried rl, but I can only get it to randomize words.
I was hoping for something like this
echo "hello" | ran
less simpler solutions are also welcome.
Sorry if the question is... (21 Replies)
This is my code:
nb_lignes=`wc -l $1 | cut -d " " -f1`
for i in $(seq $nb_lignes)
m=`head $1 -n $i | tail -1`
Please how can i change it to get Get 20% of lines in File randomly to apply "command" on each line ? 20% or 40% or 60 % (it's a parameter)
Thank you. (15 Replies)
i want to generate a random number through a script, and even if anyone reads the script, they wont be able to figure out what the random number is. only the person who setup the script would know it.
something like this could work: random
the full thread is here:
... (13 Replies)
I have two files containing hundreds of different sequences with the same Identifiers (ID-001, ID-002, etc.,), something like this:
ID-003... (18 Replies)
I've been attempting to create a script that downloads web pages at random intervals to mimic typical user usage. However I'm struggling to link $url to the URL list and thus wget complains of a missing URL. Any ideas?
url1="http://www.bbc.co.uk"... (14 Replies)
I have a column which have 7200 numbers and I am deciding to pick up 1440 numbers randomly without any reputation? Could any one let me know which script in unix will be work for my case?
Sajjad (17 Replies)
I am in a terrible emergency. I have multiple cdr files with line count >6000.
I need to append |0| | | | | | | |random| to end of each line. The random number should never repeat.
Please help with a shell script to process all cdr's in a directory with above requirement. (23 Replies)
I just got my hands on a T5120 running Sol10. As far as I've read, the T2 chip has a built-in hardware number generator. My question is: how can I access it to get random numbers in either C or Fortran? I'm using Sun Studio 12.4.
I am currently trying to write an... (13 Replies)
first of all this is not homework...this is a new type of exercise for practicing vocabulary with my students.
I have a file consisting of two columns, separated by a tab, each line consisting of a word and its definition, separated by a line break.
What i need is to replace a... (15 Replies)