From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,30d4161ec85becee,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-09 13:30:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsmi-us.news.garr.it!NewsITBone-GARR!area.cu.mi.it!news.mailgate.org!fr.clara.net!heighliner.fr.clara.net!freenix!enst!enst.fr!not-for-mail From: Mars Gralia Newsgroups: comp.lang.ada Subject: Building on Random_Float? Date: Thu, 09 May 2002 16:29:07 -0400 (EDT) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT X-Trace: avanie.enst.fr 1020976203 28129 137.194.161.2 (9 May 2002 20:30:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Thu, 9 May 2002 20:30:03 +0000 (UTC) Return-Path: X-Mailer: ELM [version 2.5 PL6] Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:23802 Date: 2002-05-09T16:29:07-04:00 Ada Wizards and Gentle Folk, I would like a high-level Ada95 design that allows me to build a layered series of random number generators which ultimately use Ada.Numerics.Float_Random. Could you please provide me one? Details are given below. Thank you, Mars Gralia, D.Sc. The Johns Hopkins University Applied Physics Laboratory gralia@jhuapl.edu 443.778.5509 (USA) Appendix A: Software Specification Appendix B: Specification Amplification Appendix C: Background Appendix D: Desired Specification Files ----------------- Appendix A: Software Specification 10) The goal is a "package Interest_Rate_Pkg", which produces random numbers from a gamma distribution. 20) The "package specification", file Interest_Rate_Pkg.ads, differs form Ada.Numerics.Float_Random only a) in the package name and b) the data type Uniformly_Distributed b1) declaration is eliminated b2) is converted to "Float" for the "function Random". 30) The package is built in the following layers: package Interest_Rate_Pkg, which "withs" package General_Gamma_Pkg, which "withs" package Standard_Gamma_Pkg, which "withs" package Exponential_Pkg, which "withs" package Ada.Numerics.Float_Random; package Normal_Pkg, which "withs" package Ada.Numerics.Float_Random; package Ada.Numerics.Float_Random. 40) I am not requesting the algorithms, for I have all of them. Indeed, they run with the uniform generator the author supplies. But I prefer the Ada95 generator as the basis. ----------------- Appendix B: Specification Details 10) This note more carefully defines the family of generators I would like to use. It's code skelton is: package Interest_Rate_Pkg is ... end Interest_Rate_Pkg; with General_Gamma_Pkg; package body Interest_Rate_Pkg is ... end Interest_Rate_Pkg; package General_Gamma_Pkg is ... end General_Gamma_Pkg; with Standard_Gamma_Pkg; package body General_Gamma_Pkg is ... end General_Gamma_Pkg; package Standard_Gamma_Pkg is ... end Standard_Gamma_Pkg; with Normal_Pkg, Exponential_Pkg, Ada.Numerics.Float_Random; package body Standard_Gamma_Pkg is ... end Standard_Gamma_Pkg; package Exponential_Pkg is ... end Exponential_Pkg; with Ada.Numerics.Float_Random; package body Exponential_Pkg is ... end Exponential_Pkg; package Normal_Pkg is ... end Normal_Pkg; with Ada.Numerics.Float_Random; package body Normal_Pkg is ... end Normal_Pkg; 20) I would prefer the technology allow me to continue the layering even deeper than the four levels I need in this example. ----------------- Appendix C: Background I'm working under Gnat 3.13p, but would like to use only standard Ada. I've tried, and failed: a) To simply build the second layer on Ada.Numerics.Float_Random. As expected, this failed because Float_Random is a "limited private", so I can't use an assignment statement to store it in Normal_Pkg.Generator. b) To make a package Ada.Numerics.Float_Random.Normal. The specific message was: --> ada.numerics.float_random.random_brown_pkg.ads:1:01: --> current unit cannot depend on "Float_Random" (wrong --> categorization) c) To use pointers as did Mr. Eachus in his ADAR_Random_Number. Hint: I got it from the Google archives. It had the header: --> From: Robert I. Eachus (eachus@spectre.mitre.org) --> Subject: Re: Random number generators --> Newsgroups: comp.lang.ada --> Date: 1995/07/25 I feel I'm a journeyman programmer, certainly not a formal student. (But aren't we all still learning?) The source of my current algorithm for all the layers are found in http://odin.mdacc.tmc.edu/anonftp/page_2.html#RANDLIB They were developed by Barry W. Brown, James Lovato, Kathy Russell and John Venier. On the web, it was called "randlib". Internally, it is labeled "RANDLIB; Library of Fortran Routines for Random Number Generation; Version 1.3 -- August, 1997". The authors are with the > Department of Biomathematics, Box 237; > The University of Texas, M.D. Anderson Cancer Center; > 1515 Holcombe Boulevard; > Houston, TX 77030 They also tell us "This work was supported by grant CA-16672 from the National Cancer Institute." ----------------- Appendix D: Desired Specification Files This section gives the package specs I'd like to have in the end. Note they are virtually identical. package Interest_Rate_Pkg is type Generator is limited private; function Random (Gen: Generator) return Float; procedure Reset (Gen: in Generator; Initiator: in Integer); procedure Reset (Gen: in Generator); type State is private; procedure Save (Gen: in Generator; To_State: out State); procedure Reset (Gen: in Generator; From_State: in State); Max_Image_Width: constant := implementation-defined integer value; function Image (Of_State: State) return String; function Value (Coded_State: String) return State; private ... -- not specified by Gralia end Interest_Rate_Pkg; package General_Gamma_Pkg is type Generator is limited private; function Random (Gen: Generator) return Float; procedure Reset (Gen: in Generator; Initiator: in Integer); procedure Reset (Gen: in Generator); type State is private; procedure Save (Gen: in Generator; To_State: out State); procedure Reset (Gen: in Generator; From_State: in State); Max_Image_Width: constant := implementation-defined integer value; function Image (Of_State: State) return String; function Value (Coded_State: String) return State; private ... -- not specified by Gralia end General_Gamma_Pkg; package Standard_Gamma_Pkg is type Generator is limited private; function Random (Gen: Generator) return Float; procedure Reset (Gen: in Generator; Initiator: in Integer); procedure Reset (Gen: in Generator); type State is private; procedure Save (Gen: in Generator; To_State: out State); procedure Reset (Gen: in Generator; From_State: in State); Max_Image_Width: constant := implementation-defined integer value; function Image (Of_State: State) return String; function Value (Coded_State: String) return State; private ... -- not specified by Gralia end Standard_Gamma_Pkg; package Exponential_Pkg is type Generator is limited private; function Random (Gen: Generator) return Float; procedure Reset (Gen: in Generator; Initiator: in Integer); procedure Reset (Gen: in Generator); type State is private; procedure Save (Gen: in Generator; To_State: out State); procedure Reset (Gen: in Generator; From_State: in State); Max_Image_Width: constant := implementation-defined integer value; function Image (Of_State: State) return String; function Value (Coded_State: String) return State; private ... -- not specified by Gralia end Exponential_Pkg; package Normal_Pkg is type Generator is limited private; function Random (Gen: Generator) return Float; procedure Reset (Gen: in Generator; Initiator: in Integer); procedure Reset (Gen: in Generator); type State is private; procedure Save (Gen: in Generator; To_State: out State); procedure Reset (Gen: in Generator; From_State: in State); Max_Image_Width: constant := implementation-defined integer value; function Image (Of_State: State) return String; function Value (Coded_State: String) return State; private ... -- not specified by Gralia end Normal_Pkg; (end of note)