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.discreteuniform - Function Up: randomnumbers - Tool Previous: randomnumbers - Constructor


randomnumbers.binomial - Function



Package utility
Module mathematics
Tool randomnumbers


Generate binomially distributed random numbers


Synopsis
binomial(number, probability, shape)


Description
The binomial function will generate numbers that follow a binomial distribution. See the general tool description for a definition of the point probabilities.

The number, N, can be any positive integer and the probability must be a number between zero and one. The result will be integers in the range 0 $ \leq$ x $ \leq$ N. The shape can be either an integer or a vector of integers where all the values are greater than zero. The default value of one will produce a scalar output.



Arguments

number in Number of trials
    Allowed: integer
    Default: 1
probability in probability of success for one trial
    Allowed: double
    Default: 0.5
shape in Shape of the output array
    Allowed: integer or a vector of integers
    Default: 1


Returns
An integer scalar or array.


Example
      include 'randomnumbers.g'
      rand := randomnumbers();
      print rand.binomial(2, shape=100);
      rand.done()
This example will print random numbers that correspond to tossing two coins one hundred time and counting the number of heads. Hence zero will appear one quarter of the time, one appear half of the time and two will appear one quarter of the time.



next up previous contents index
Next: randomnumbers.discreteuniform - Function Up: randomnumbers - Tool Previous: randomnumbers - Constructor   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