- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Generating Random Numbers.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2011 10:51 AM
тАО02-15-2011 10:51 AM
Dave.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2011 11:06 AM
тАО02-15-2011 11:06 AM
Re: Generating Random Numbers.
Based on a quick Google, the core of MTH$RANDOM call is akin to SEED = (69069*SEED + 1) mod 2**32, and X = SEED/2**32, RETURN X. It's all of a handful of instructions, at most.
There's $hash_password
The OpenSSL stuff has a random function.
There are the message digest calls, too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2011 11:06 AM
тАО02-15-2011 11:06 AM
Re: Generating Random Numbers.
Hi Dave,
What makes you think MTH$RANDOM went away?
The HELP may be gone, but the code is there just fine. Has to be... compatibility.
Any particular language you'd like to use it from? For example, C has its own RAND.
The example below, from the Cobol Users still works fine on 8.3.
Also two old wizard articles:
http://h71000.www7.hp.com/wizard/march-96/question_2.html
http://h71000.www7.hp.com/wizard/wiz_9817.htm
Hope this helps some,
Hein
http://h71000.www7.hp.com/doc/82final/6297/6297pro_100.html
IDENTIFICATION DIVISION.
PROGRAM-ID. RUNTIME.
*****************************************************
* This program calls MTH$RANDOM, a random number *
* generator from the Run-Time Library. *
*****************************************************
DATA DIVISION.
WORKING-STORAGE SECTION.
01 SEED PIC 9(5) COMP VALUE 967.
01 A-NUM COMP-1.
01 C-NUM PIC Z(5).
PROCEDURE DIVISION.
GET-RANDOM-NO.
PERFORM 10 TIMES
CALL "MTH$RANDOM" USING SEED GIVING A-NUM
MULTIPLY A-NUM BY 100 GIVING C-NUM
DISPLAY "Random Number is " C-NUM
END-PERFORM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2011 11:13 AM
тАО02-15-2011 11:13 AM
Re: Generating Random Numbers.
Hoff,
I pointed him to the C RTL, and gave him a link to the documentation (for OpenVMS 8.3).
I was just wondering if there was a system routine he could call directly.
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2011 12:01 PM
тАО02-15-2011 12:01 PM
Re: Generating Random Numbers.
Let us know if you need a better generator.
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2011 12:53 PM
тАО02-15-2011 12:53 PM
Re: Generating Random Numbers.
http://en.wikipedia.org/wiki/Mersenne_twister
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2011 01:03 PM
тАО02-15-2011 01:03 PM
Re: Generating Random Numbers.
MTH$RANDOM is still there, insofar as I know. Whether it is suitable for the intended application is a far more subtle question.
My recollection (I do not have the manuals with me where I am sitting at this instant) is that MTH$RANDOM is a linear congruential generator. Having done some work over the years in the random number "playground", there are some purposes for which that is adequate, and there are some that it is not. A review of a good text is in order before considering this question. Knuth Volume 2 (Seminumerical Algorithms) is one of the classic references. Alternatively, consult someone who has familiarity with the issues.
One of the original widely distributed random number generators (as part of a Scientific Subroutine Package known as SSP), had coefficients which were poor choices. My understanding is that this did result in some problems with simulations (my recollection is that Knuth Volume 2 has the discussion, as do several other numerical methods text that cover random numbers).
There is a snippet of the the help text for MTH$RANDOM at:
http://h71000.www7.hp.com/wizard/march-96/question_2.html
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2011 03:58 PM
тАО02-15-2011 03:58 PM
Re: Generating Random Numbers.
However, be careful with the data type of the return value. I believe it's F_FLOAT. Make sure you deal with any necessary conversions if you're using IEEE floating point types.
I disagree with Dan's assertion "Please also realize that this random function is poor at best."
The choice of parameters for the algorithm is based on Knuth, and is about as good as you'll get for a 32 bit implementation of a mixed congruential generator.
If you want a "true" random number generator (as opposed to a deterministic one which will return the same sequence for a given seed), you can't do it using a deterministic system. You'll need some physical device which gets numbers from truly random events, such as radioactive decay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2011 05:27 PM
тАО02-15-2011 05:27 PM
SolutionThe sys$create_uid call can be useful for some tasks where folks have sought random numbers, as can be the f$unique DCL lexical function, for instance.
The simplest answer here may well be the right one.
Or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-15-2011 07:07 PM
тАО02-15-2011 07:07 PM
Re: Generating Random Numbers.
sys$create_uid and f$unique are essentially the same. F$UNIQUE just translates the UID into a hex string (or some permutation of it).
However, these numbers, as returned, are definitely NOT random. They fail immediately because they're guaranteed to be monotonic increasing, and they're highly correlated with the time.
For some purposes you could select a fast varying region of the returned string. This MAY be random enough for some purposes, but you're effectively randomising on the time period between calls. I doubt you'll find any simple algorithm that generate give plausible random numbers in a loop calling F$UNIQUE.