Sponsored Content
Full Discussion: Question about erand48 usage
Top Forums Programming Question about erand48 usage Post 302463100 by santosh_sugur on Friday 15th of October 2010 05:20:30 PM
Old 10-15-2010
@fpmurphy - Moving
Code:
unsigned short xsubi[3];

outside solves my problem!

Thanks for all replies. This is the first time i'm using erand48, but after reading the man page I felt that you do not need to call any of the seed functions and in effect you set the seed by initializing the Xi value. Doing
Code:
xsubi[0] = 10

I thought was achieving that, may be not filling all of the 48 bits, was an issue. I also tested this by initializing xsubi[0] to a different value and then I would get a new set of random numbers. All of this is what I wanted except that putting the floor call then somehow stopped giving me a consistent set of random numbers.
 

10 More Discussions You Might Find Interesting

1. AIX

basic question about disk usage

how to i find out the disk usage on a server. say in windows examples its like C:/ D:/ and checking out the disk space. how can i find in Unix. can i just use df -k (3 Replies)
Discussion started by: karthikosu
3 Replies

2. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

3. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

4. Shell Programming and Scripting

usage of sed question for experts

I need a little help with sed. Basically, I need to parse out selections from the output of hddtemp so conky can display some hdd temps for me. I have hddtemp in daemon mode so A simple 'nc localhost 7634' displays the following: $ nc localhost 7634... (3 Replies)
Discussion started by: audiophile
3 Replies

5. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

6. UNIX for Dummies Questions & Answers

rsync usage question

Hello folks; I'm using rsync on my Ubuntu servers to sync a remote folders on a remote machine to a local folders on a local machine. one thing i couldn't get to work is how to exclude folder. I know i'm suppose to use "exclude" argument but every time i do, i still see the excluded directory... (0 Replies)
Discussion started by: Katkota
0 Replies

7. Shell Programming and Scripting

Question regarding sed usage

I have a html file with the following content:- <font face=verdana color=#000000>108946</font> <font face=verdana color=#000000>234346</font> I want to format the values inside the font tag using thousand separator. I have the following command which can be used for adding thousand... (4 Replies)
Discussion started by: Yoda
4 Replies

8. UNIX for Dummies Questions & Answers

Ln usage question

Is it possible to assign a symbolic link to a network folder, without that folder being mounted? Thanks! (1 Reply)
Discussion started by: nerdcurious
1 Replies

9. UNIX for Dummies Questions & Answers

Question on disk size and usage

Hello All, this may be a simple question but I wasn't sure how to word it to search for the answer. Have a look at the following: /dev/mapper/vgdata-lvdata 626G 594G 0 100% /data01 As you can see the disk size 626GB of which 594G is used. There's 32GB difference there but the... (5 Replies)
Discussion started by: bbbngowc
5 Replies

10. UNIX for Beginners Questions & Answers

Sed command usage question

How to work x in sed command? I know x command is swaps the contents of pattern space and hold space. But i am unable to understand it's working? (4 Replies)
Discussion started by: Vartika18
4 Replies
RAND48(3)						   BSD Library Functions Manual 						 RAND48(3)

NAME
drand48, erand48, jrand48, lcong48, lrand48, mrand48, nrand48, seed48, srand48 -- pseudo random number generators and initialization routines LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdlib.h> double drand48(void); double erand48(unsigned short xsubi[3]); long jrand48(unsigned short xsubi[3]); void lcong48(unsigned short param[7]); long lrand48(void); long mrand48(void); long nrand48(unsigned short xsubi[3]); unsigned short * seed48(unsigned short seed16v[3]); void srand48(long seedval); DESCRIPTION
The rand48() family of functions generates pseudo-random numbers, using a linear congruential algorithm working on integers 48 bits in size. The particular formula employed is r(n+1) = (a * r(n) + c) mod m. The default value for the multiplicand `a' is 0x5deece66d (25214903917). The default value for the the addend `c' is 0xb (11). The modulo is always fixed at m = 2 ** 48. r(n) is called the seed of the random num- ber generator. For the six generator routines described next, the first computational step is to perform a single iteration of the algorithm. The drand48() and erand48() functions return values of type double. The full 48 bits of r(n+1) are loaded into the mantissa of the returned value, with the exponent set such that the values produced lie in the interval [0.0, 1.0). The lrand48() and nrand48() functions return values of type long in the range [0, 2**31-1]. The high-order (31) bits of r(n+1) are loaded into the lower bits of the returned value, with the topmost (sign) bit set to zero. The mrand48() and jrand48() functions return values of type long in the range [-2**31, 2**31-1]. The high-order (32) bits of r(n+1) are loaded into the returned value. The drand48(), lrand48(), and mrand48() functions use an internal buffer to store r(n). For these functions the initial value of r(0) = 0x1234abcd330e = 20017429951246. On the other hand, erand48(), nrand48(), and jrand48() use a user-supplied buffer to store the seed r(n), which consists of an array of 3 shorts, where the zeroth member holds the least significant bits. All functions share the same multiplicand and addend. The srand48() function is used to initialize the internal buffer r(n) of drand48(), lrand48(), and mrand48(), such that the 32 bits of the seed value are copied into the upper 32 bits of r(n), with the lower 16 bits of r(n) arbitrarily being set to 0x330e. Additionally, the con- stant multiplicand and addend of the algorithm are reset to the default values given above. The seed48() function also initializes the internal buffer r(n) of drand48(), lrand48(), and mrand48(), but here all 48 bits of the seed can be specified in an array of 3 shorts, where the zeroth member specifies the lowest bits. Again, the constant multiplicand and addend of the algorithm are reset to the default values given above. The seed48() function returns a pointer to an array of 3 shorts which contains the old seed. This array is statically allocated; thus, its contents are lost after each new call to seed48(). Finally, lcong48() allows full control over the multiplicand and addend used in drand48(), erand48(), lrand48(), nrand48(), mrand48(), and jrand48(), and the seed used in drand48(), lrand48(), and mrand48(). An array of 7 shorts is passed as argument; the first three shorts are used to initialize the seed; the second three are used to initialize the multiplicand; and the last short is used to initialize the addend. It is thus not possible to use values greater than 0xffff as the addend. Note that all three methods of seeding the random number generator always also set the multiplicand and addend for any of the six generator calls. For a more powerful random number generator, see random(3). SEE ALSO
rand(3), random(3) AUTHORS
Martin Birgmeier BSD
October 8, 1993 BSD
All times are GMT -4. The time now is 12:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy