o_runif: Drawing from R Uniform Distribution in Octave

Description Usage Arguments Value Difference with plain runif Seeding Octave details Octave Documentation for rand See Also Examples

View source: R/random.R

Description

This function wraps a call to the standard Octave function rand, which is redefined by RcppOctave to call the R base function runif. This enables to exactly reproduce stochastic computations in R and Octave, without changing the original Octave/Matlab code.

Usage

1
o_runif(n, p = n)

Arguments

n

number of output rows

p

number of output columns (default to n)

Value

a numeric vector or a matrix

Difference with plain runif

Since calling o_runif or runif is equivalent, this function may not be really useful for the end user, and is defined for testing purposes essentially. One possible advantage over plain runif however, is that it can generate random matrices, instead of only vectors (see examples).

Seeding

Because the RNG of R is called used, seeding computations is achieved by a standard call to set.seed.

Octave details

RcppOctave defines a set of functions like rand that shadow Octave built-in functions. These functions are defined in the Octave module Rrng.oct that is stored in the package modules/ sub-directory. See Octave.info('modules') to see this directory's full path.

Octave Documentation for rand

\Sexpr[results=rd,stage=render]{if( .Platform$OS.type != 'windows' || .Platform$r_arch != 'x64' ) RcppOctave::o_help(rand, format='rd')}

[Generated from Octave-\Sexpr{RcppOctave::o_version()} on \Sexpr{Sys.time()}]

See Also

runif

Other orandom: o_rexp, o_rgamma, o_rnorm, o_rpois

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Draw random uniform values (in vector form)
set.seed(123)
o_runif(1)
o_runif(1, 10)
# The result is identical as calling runif  
set.seed(123)
runif(1)
runif(10)

# Draw random uniform values (in matrix form)
set.seed(123)
o_runif(2)
o_runif(2, 5)

renozao/RcppOctave documentation built on June 30, 2017, 2:11 p.m.