Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: randomnumbers.binomial - Function Up: randomnumbers - Tool Previous: randomnumbers - Tool


randomnumbers - Constructor



Package utility
Module mathematics
Tool randomnumbers


Construct an randomnumbers tool


Synopsis
randomnumbers(host, forcenewserver)


Description
Use this constructor to create a randomnumbers tool. This is the only way to create such a tool. After construction all randomnumbers tools are identical and will produce the same sequence of randomnumbers. To change this you need to use the reseed function.

The host argument specifies which machine the precompiled server process should be started on. The default value of unset starts it on the same machine as the one that glish is running on. Starting a server process on a remote machine allows you to use the memory and cpu on that machine. As the randomnumbers tool does not use much memory or processor time this is usually not worth it.

In order to run the server process on a remote machine you need to satisfy all the following conditions.

  • It must be possible to start AIPS++ on the remote machine
  • You must be able to log onto the remote machine without having to type a password
  • The AIPSPATH environment variable must be defined on the remote machine. You may want to set this up in the relevant ``dot'' file eg., adding a line like source /usr/local/aips++/aipsinit.csh in your .cshrc file (for csh).
One quick way to check if all three conditions are met is to type, on your local machine:
        rsh host 'echo \$AIPSPATH'
where host is replaced by the name of the remote machine. If the value of the AIPSPATH variable that is printed does not contain something like aips-root architecture site host and that all the values are correct for the remote machine you can be certain that starting the any AIPS++ server, on the remote host will not work

Each server process can only run one function at a time. Hence it is not possible, for example, to simultaneously calculate two different random numbers sequences using one server. To solve this you start two servers. The forcenewserver argument allows you to do this by overriding the default behaviour of having each randomnumbers tool share the same server.

For the randomnumbers tool, in 99.99% of all cases, the default values for the host and forcenewserver arguments will be fine.



Arguments

host in The host on which the server process should be run
    Allowed: string
    Default: unset
forcenewserver in Always start a new server
    Allowed: Boolean
    Default: F


Returns
A randomnumbers tool



Example
      include 'randomnumbers.g'
      rand := randomnumbers();
      rand.reseed(10);
      print rand.uniform(-1, 3, 4);
      print rand.discreteuniform(-1, 3, [4,2]);
      rand.done()
This example creates a randomnumbers tool, and sets the seed to a new value. It then prints the values for random numbers from two different, but similar distributions. Finally the tool is shutdown to release all the memory it has consumed.



next up previous contents index
Next: randomnumbers.binomial - Function Up: randomnumbers - Tool Previous: randomnumbers - Tool   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15