GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • » Octave core
  • » by package
  • » alphabetical

This view

  • Original page
  • New address

GeezerVison is showing octave.sourceforge.io — Function Reference: randi

Octave-Forge - Extra packages for GNU Octave
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code

Navigation

Operators and Keywords

Function List:

  • » Octave core
  • » by package
  • » alphabetical

C++ API

: randi (imax)
: randi (imax, n)
: randi (imax, m, n, …)
: randi ([imin imax], …)
: randi (…, "class")

Return random integers in the range 1:imax.

Additional arguments determine the shape of the return matrix. When no arguments are specified a single random integer is returned. If one argument n is specified then a square matrix (n x n) is returned. Two or more arguments will return a multi-dimensional matrix (m x n x …).

The integer range may optionally be described by a two element matrix with a lower and upper bound in which case the returned integers will be on the interval [imin, imax].

The optional argument class will return a matrix of the requested type. The default is "double".

The following example returns 150 integers in the range 1–10.

ri = randi (10, 150, 1)

Implementation Note: randi relies internally on rand which uses class "double" to represent numbers. This limits the maximum integer (imax) and range (imax - imin) to the value returned by the flintmax function. For IEEE floating point numbers this value is 2^{53} - 1.

See also: rand.

Package: octave

SourceForge.net Logo
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.