Sponsored Content
Full Discussion: Random Numbers - Perl
Top Forums Shell Programming and Scripting Random Numbers - Perl Post 302298997 by pludi on Thursday 19th of March 2009 02:23:49 AM
Old 03-19-2009
Excuse me if I might sound thick, but what exactly do you want to do with that script? I tried it and, some "uninitialized value" warnings aside, nothing happened. The output file wasn't much different than the input file and certainly didn't contain any random numbers.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Random numbers without repetition

Is anyone know some scripts to generate random number without repetition using bash; for example generate 10 different random numbers. Thanks (8 Replies)
Discussion started by: asal_email
8 Replies

2. Shell Programming and Scripting

genrating pseudo random numbers

I want to generate the file in following format -------------------------------------- mov t1, %r1 mov t2, %g1 mov t3, %o1 . . . . m times add %r1, %g1, %o1 add %r2, %g2, %o2 . . . n times ------------------------------------------- (7 Replies)
Discussion started by: hack_tom
7 Replies

3. Shell Programming and Scripting

Random numbers from 0 to 1000

Hello All, I want to make a simple script which generate random number from 0 to 1000. and simply display it. Plz HELP!!!!!! Regards, Waqas Ahmed (2 Replies)
Discussion started by: wakhan
2 Replies

4. Shell Programming and Scripting

Random NUmbers Generation with out repetation

Hi I have the below code MAXCOUNT=10 count=1 echo echo "$MAXCOUNT random numbers:" echo "-----------------" while # Generate 10 ($MAXCOUNT) random integers. do number=$ + 1 ] "echo $number" let "count += 1" # Increment count. done But aftre executing this ... (8 Replies)
Discussion started by: lalitka
8 Replies

5. Shell Programming and Scripting

Generating random numbers

Hi, I am having trouble with generating random numbers. can this be done with awk? So I have a file that looks like this: 23 30 24 40 26 34 So column1 is start and column2 is end. I want to generate 3 random #'s between start and stop: So the output will look like this: ... (9 Replies)
Discussion started by: phil_heath
9 Replies

6. Programming

generate array of random numbers

hi guys, I am writing a c program that generates a two dimensional array to make matrix and a vector of random numbers and perform multiplication. I can't figure out whats wrong with my code. It generates a matrix of random numbers but all the numbers in the vector array is same and so is the... (2 Replies)
Discussion started by: saboture88
2 Replies

7. Shell Programming and Scripting

A way to store 2 random numbers from a for loop?

I have a for loop that cycles twice and generates 1 random number for each pass through. I would like to be able to store the two numbers to use later for arithmetics. Is there a way to do that? Right now I can only seem to use the last random number for anything. Thanks. (4 Replies)
Discussion started by: AxlVanDamme
4 Replies

8. Shell Programming and Scripting

unique random numbers awk

Hi, I have a small piece of awk code (see below) that generates random numbers. gawk -F"," 'BEGIN { srand(); for (i = 1; i <= 30; i++) printf("%s AM329_%04d\n",$0,int(36 * rand())+1) }' OFS=, AM329_hole_names.csv The code works fine and generates alphanumeric numbers like AM329_0001,... (2 Replies)
Discussion started by: theflamingmoe
2 Replies

9. Homework & Coursework Questions

Random numbers

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! Write a shell script that will take the sum of two random number? Ex: Random n1 +Random n2 = result i tries to write it but i had some dufficulties ... (3 Replies)
Discussion started by: renegade755
3 Replies
RANDOM(3)						     Linux Programmer's Manual							 RANDOM(3)

NAME
random, srandom, initstate, setstate - random number generator SYNOPSIS
#include <stdlib.h> long int random(void); void srandom(unsigned int seed); char *initstate(unsigned int seed, char *state, size_t n); char *setstate(char *state); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): random(), srandom(), initstate(), setstate(): _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED DESCRIPTION
The random() function uses a nonlinear additive feedback random number generator employing a default table of size 31 long integers to return successive pseudo-random numbers in the range from 0 to RAND_MAX. The period of this random number generator is very large, approx- imately 16 * ((2^31) - 1). The srandom() function sets its argument as the seed for a new sequence of pseudo-random integers to be returned by random(). These sequences are repeatable by calling srandom() with the same seed value. If no seed value is provided, the random() function is automati- cally seeded with a value of 1. The initstate() function allows a state array state to be initialized for use by random(). The size of the state array n is used by init- state() to decide how sophisticated a random number generator it should use -- the larger the state array, the better the random numbers will be. seed is the seed for the initialization, which specifies a starting point for the random number sequence, and provides for restarting at the same point. The setstate() function changes the state array used by the random() function. The state array state is used for random number generation until the next call to initstate() or setstate(). state must first have been initialized using initstate() or be the result of a previous call of setstate(). RETURN VALUE
The random() function returns a value between 0 and RAND_MAX. The srandom() function returns no value. The initstate() function returns a pointer to the previous state array. The setstate() function returns a pointer to the previous state array, or NULL on error. ERRORS
EINVAL A state array of less than 8 bytes was specified to initstate(). CONFORMING TO
4.3BSD, POSIX.1-2001. NOTES
Current "optimal" values for the size of the state array n are 8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to the nearest known amount. Using less than 8 bytes will cause an error. This function should not be used in cases where multiple threads use random() and the behavior should be reproducible. Use random_r(3) for that purpose. Random-number generation is a complex topic. Numerical Recipes in C: The Art of Scientific Computing (William H. Press, Brian P. Flannery, Saul A. Teukolsky, William T. Vetterling; New York: Cambridge University Press, 2007, 3rd ed.) provides an excellent discussion of practi- cal random-number generation issues in Chapter 7 (Random Numbers). For a more theoretical discussion which also covers many practical issues in depth, see Chapter 3 (Random Numbers) in Donald E. Knuth's The Art of Computer Programming, volume 2 (Seminumerical Algorithms), 2nd ed.; Reading, Massachusetts: Addison-Wesley Publishing Company, 1981. SEE ALSO
drand48(3), rand(3), random_r(3), srand(3) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2010-09-20 RANDOM(3)
All times are GMT -4. The time now is 01:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy