octave:3> randi(10)
ans = 6
octave:4> randi(10)
ans = 8
octave:5> randi(10)
ans = 8
octave:6> randi(10)
ans = 5
octave:7> randi(10)
ans = 5
octave:8> randi(10)
ans = 10
octave:9> randexp(1)
ans = 1.1759
octave:10> randexp([1,2])
ans =
0.13524 0.42576
octave:11> randexp([1,1])
ans =
0.36203 0.13617
octave:12> randexp([1,2])
ans =
1.22416 0.15220
octave:13> randexp([ones(1,10),2*ones(1,10)])
ans =
Columns 1 through 6:
1.6790e+00 2.0781e+00 1.2434e+00 1.4448e-01 3.3616e+00 2.5132e-01
Columns 7 through 12:
2.2179e+00 8.1158e-01 7.8417e-01 9.1867e-01 5.1650e-04 8.2149e-01
Columns 13 through 18:
7.6127e-01 4.6393e-03 7.3359e-02 1.9372e+00 3.0715e-01 3.5326e-01
Columns 19 and 20:
1.4502e+00 1.0698e-02
octave:14> help rande
'rande' is a built-in function from the file libinterp/corefcn/rand.cc
-- Built-in Function: rande (N)
-- Built-in Function: rande (M, N, ...)
-- Built-in Function: rande ([M N ...])
-- Built-in Function: V = rande ("state")
-- Built-in Function: rande ("state", V)
-- Built-in Function: rande ("state", "reset")
-- Built-in Function: V = rande ("seed")
-- Built-in Function: rande ("seed", V)
-- Built-in Function: rande ("seed", "reset")
-- Built-in Function: rande (..., "single")
-- Built-in Function: rande (..., "double")
Return a matrix with exponentially distributed random elements.
The arguments are handled the same as the arguments for 'rand'.
By default, 'randn' uses the Marsaglia and Tsang "Ziggurat
technique" to transform from a uniform to an exponential
distribution.
The class of the value returned can be controlled by a trailing
"double" or "single" argument. These are the only valid classes.
Reference: G. Marsaglia and W.W. Tsang, 'Ziggurat Method for
Generating Random Variables', J. Statistical Software, vol 5, 2000,
)
See also: rand, randn, randg, randp.
Additional help for built-in functions and operators is
available in the online version of the manual. Use the command
'doc ' to search the manual index.
Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help@octave.org
mailing list.
octave:15> sin(pi)
ans = 1.2246e-16
octave:16> demo testva
testva example 1:
testva (@randexp, 3*ones(1000,1))
octave:17> testva (@randexp, 3*ones(1000,1))
octave:18> close all
octave:19> testva (@randexp, 3*ones(1000,1))
octave:20> close all,testva (@randnorm, zeros(1000,1),ones(1000,1))
octave:21> close all,testva (@randnorm, zeros(1000,1),ones(1000,1))
octave:22> close all,testva (@randnorm, zeros(10000,1),ones(10000,1))
octave:23> close all,testva (@randnorm, zeros(1000,1),ones(1000,1))
octave:24> close all,testva (@randnorm, zeros(100,1),ones(100,1))
octave:25> close all,testva (@randnorm, zeros(100,1),ones(100,1))
octave:26> close all
octave:27> simulacodamm1
Elapsed time is 19.8809 seconds.
Elapsed time is 20.9155 seconds.
octave:28> simulacodamm1
Elapsed time is 19.7247 seconds.
Elapsed time is 19.4157 seconds.
octave:29> simulacodamm1
Elapsed time is 19.2483 seconds.
Elapsed time is 17.8319 seconds.
octave:30> simulacodamm1
Elapsed time is 39.4139 seconds.
Elapsed time is 35.0908 seconds.
octave:31> help randi
'randi' is a function from the file /usr/share/octave/3.8.1/m/general/randi.m
-- Function File: randi (IMAX)
-- Function File: randi (IMAX, N)
-- Function File: randi (IMAX, M, N, ...)
-- Function File: randi ([IMIN IMAX], ...)
-- Function File: 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
'bitmax' function. For IEEE floating point numbers this value is
2^{53} - 1.
See also: rand.
Additional help for built-in functions and operators is
available in the online version of the manual. Use the command
'doc ' to search the manual index.
Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help@octave.org
mailing list.
octave:32> 6004799503160661
ans = 6.0048e+15
octave:33> intmax
ans = 2147483647
octave:34> a = randi(6004799503160661,10000,1);
octave:35> size(a)
ans =
10000 1
octave:36> length(find(mod(a,2)==0))
ans = 4624
octave:37> mod(3,2)
ans = 1
octave:38> mod(4,2)
ans = 0
octave:39> length(find(mod(a,2)==1))
ans = 5376
octave:40> a = randi(6004799503160661,10000,1);
octave:41> length(find(mod(a,2)==1))
ans = 5408
octave:42> length(find(mod(a,2)==0))
ans = 4592
octave:43> diary off