random

From DavinciWiki
Jump to: navigation, search


64-bit SafeYes

Description

Generates random numbers

Arguments and Return Values

Arguments: dimension and seed parameters

Return Value: a numeric array containing random numbers

Usage

Syntax: random([x = INT] [, y = INT] [, z = INT] [, seed = INT] [, type = STRING])

The random() function generates random numbers, with a distribution specified by the type parameter.

The possible values for type, and the types of numbers generates are:

type        distribution    type    interval
-------     ------------    ----    ------------
uniform     uniform         float   [0.0, 1.0]          # default value
drand48     uniform         float   [0.0, 1.0]
mrand48     uniform         int     [-2^31, 2^31]
normal      gaussian        float   *
gauss       gaussian        float   *
rand        simple          int     [0, (2^15)-1]
random      simple          int     [0, (2*31)-1]

The gaussian distribution has a mean of 0.0, and a standard deviation of 1.0.

The value seed can be specified to seed any of the random number generators, to produce reproducable random numbers. Any dimension not specified defaults to a value of 1.

Some of these types may not be available on all systems.

Examples

dv> random(3,3,3)
3x3x3 array of float, bsq format [108 bytes]
0.826597        0.879055        0.604216
0.778096        0.205341        0.293955
0.257071        0.240723        0.720289

0.147112        0.399489        0.835683
0.356612        0.185553        0.978434
0.659467        0.114649        0.558853

0.436106        0.803163        0.133404
0.414845        0.194053        0.433575
0.833470        0.0127538       0.520705

dv> random()
0.516770

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Related Functions

Recent Core Changes

Modified On: 07-06-2009

Personal tools