01-20-2009
Post the entire code. You are missing the code listing for the random number generator KISS_RNG.
10 More Discussions You Might Find Interesting
1. Filesystems, Disks and Memory
why do inode indices starts from 1 unlike array indexes which starts from 0
its a question from "the design of unix operating system" of maurice j bach
id be glad if i get to know the answer quickly
:) (0 Replies)
Discussion started by: sairamdevotee
0 Replies
2. UNIX for Dummies Questions & Answers
brothers why inode index starts from 1 unlike array inex which starts from 0
its a question from the design of unix operating system of maurice j.bach
i need to know the answer urgently...someone help please (1 Reply)
Discussion started by: sairamdevotee
1 Replies
3. UNIX for Advanced & Expert Users
hi folks
i am facing problom while trying to access sql variable as array index ina unix shell script....script goes as below..
#!/bin/ksh
MAX=3
for elem in alpha beeta gaama
do
arr=$elem
((x=x+1))
Done
SQL_SERVER='servername'
/apps/sun5/utils/sqsh -S $SQL_SERVER -U user -P pwd -b -h... (1 Reply)
Discussion started by: sudheer157
1 Replies
4. Shell Programming and Scripting
$ cat file.txt
A|X|20
A|Y|20
A|X|30
A|Z|20
B|X|10
A|Y|40
Summing up $NF based on first 2 fields,
$ awk -F "|" 'BEGIN {OFS="|"}
{ sum += $NF }
END { for (f in sum) print f,sum }
' file.txt
o/p:
A|X|50
A|Y|60
A|Z|20 (4 Replies)
Discussion started by: uwork72
4 Replies
5. Shell Programming and Scripting
Hi,
I'm just trying to use a dynamic index for some array elements that I'm accessing within a loop. Specifically, I want to access an array at variable position $counter and then also at location $counter + 1 and $counter + 2 (the second and third array positions after it) but I keep getting... (0 Replies)
Discussion started by: weak_code-fu
0 Replies
6. Programming
I have an 10 element array containing numbers, I want the start and end index in the array for which the values lie between DIST1 and DIST2. It is not working quite right. I also might want a value of 0 if I cannot find an index.
V=(/10.0,20.0,30.0,40.0,50.0,60.0,70.0,80.0,90.0,100.0/)
... (4 Replies)
Discussion started by: kristinu
4 Replies
7. Shell Programming and Scripting
Hi Everyone !
I have two files with the same configuration
and I want to multiply corresponding values and write the result in a file.
Let say 2 header lines and then lines of values (with not constant number of columns):
more file1.txt -->
BLABLABLA
BLABLABLA
1 2 3 4
1 2 3
1 2
1... (7 Replies)
Discussion started by: Youm
7 Replies
8. Programming
I want to return a char array to the main() function, but its returning garbage value.
#include<stdio.h>
//#include<conio.h>
#include<string.h>
char* strtrmm();
int main()
{
char str1,c1;
printf("\n Enter the string:");
gets(str1);
//strtrmm(str1);
printf("%s",strtrmm(str1));... (2 Replies)
Discussion started by: zinat
2 Replies
9. Shell Programming and Scripting
I am trying to assign indexes to an associative array in a for loop but I have to use an eval command to make it work, this doesn't seem correct I don't have to do this with regular arrays
For example, the following assignment fails without the eval command:
#! /bin/bash
read -d "\0" -a... (19 Replies)
Discussion started by: Riker1204
19 Replies
10. Shell Programming and Scripting
Hello,
I have a complicated situational find and replace that I wrote in bash because I didn't know how to do everything in awk. The code works but is very slow, as expected.
To create my modified file, I am looping through an array that was populated earlier and making some replacements at... (6 Replies)
Discussion started by: LMHmedchem
6 Replies
LEARN ABOUT ULTRIX
random
random(3) Library Functions Manual random(3)
Name
random, srandom, initstate, setstate - better random number generator; routines for changing generators
Syntax
long random()
void srandom(seed)
int seed;
char *initstate(seed, state, n)
unsigned seed;
char *state;
int n;
char *setstate(state)
char *state;
Description
The subroutine uses a non-linear 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 (2**31)-1. The period of this random number generator is very large, approximately
16*((2**31)-1).
The subroutines have (almost) the same calling sequence and initialization properties as The difference is that rand(3) produces a much
less random sequence - in fact, the low dozen bits generated by rand go through a cyclic pattern. All the bits generated by are usable.
For example, "random()&01" will produce a random binary value.
Unlike does not return the old seed; the reason for this is that the amount of state information used is much more than a single word.
(Two other routines are provided to deal with restarting/changing random number generators.) Like however, will by default produce a
sequence of numbers that can be duplicated by calling with 1 as the seed.
The routine allows a state array, passed in as an argument, to be initialized for future use. The size of the state array (in bytes) is
used by to decide how sophisticated a random number generator it should use - the more state, the better the random numbers will be. (Cur-
rent "optimal" values for the amount of state information 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). The seed for the initialization (which specifies a starting point for
the random number sequence, and provides for restarting at the same point) is also an argument. returns a pointer to the previous state
information array.
Once a state has been initialized, the routine provides for rapid switching between states. The subroutine returns a pointer to the previ-
ous state array; its argument state array is used for further random number generation until the next call to or
Once a state array has been initialized, it may be restarted at a different point either by calling (with the desired seed, the state
array, and its size) or by calling both (with the state array) and (with the desired seed). The advantage of calling both and is that the
size of the state array does not have to be remembered after it is initialized.
With 256 bytes of state information, the period of the random number generator is greater than 269, which should be sufficient for most
purposes.
Diagnostics
If is called with less than 8 bytes of state information, or if detects that the state information has been garbled, error messages are
printed on the standard error output.
See Also
rand(3)
random(3)