Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

Random Calculator

Random

Function: random (<x>) Returns a pseudorandom number. If <x> is an integer, random (<x>) returns an integer from 0 through <x> - 1 inclusive. If <x> is a floating point number, random (<x>) returns a nonnegative floating point number less than <x>. random complains with an error if <x> is neither an integer nor a float, or if <x> is not positive.

load (descriptive);
l1:makelist(random(10),k,1,50);
mean(l1);
mean(l1),numer;
M:mean(l1),numer;
SM:smin(l1),numer;
SN:smax(l1),numer;

The functions make_random_state and set_random_state maintain the state of the random number generator.

The Maxima random number generator is an implementation of the Mersenne twister MT 19937.

Examples:

          (%i1) s1: make_random_state (654321)$
          (%i2) set_random_state (s1);
          (%o2)                         done
          (%i3) random (1000);
          (%o3)                          768
          (%i4) random (9573684);
          (%o4)                        7657880
          (%i5) random (2^75);
          (%o5)                11804491615036831636390
          (%i6) s2: make_random_state (false)$
          (%i7) random (1.0);
          (%o7)                   .2310127244107132
          (%i8) random (10.0);
          (%o8)                   4.394553645870825
          (%i9) random (100.0);
          (%o9)                   32.28666704056853
          (%i10) set_random_state (s2);
          (%o10)                        done
          (%i11) random (1.0);
          (%o11)                  .2310127244107132
          (%i12) random (10.0);
          (%o12)                  4.394553645870825
          (%i13) random (100.0);
          (%o13)                  32.28666704056853

There are also some inexact matches for random. Try ?? random to see them.

(%o1)                                true
(%i2) 

Random Example

Related Examples

random

for i:0 thru 320 step...

x=random(1.0);

Calculate

random

U:10+random(90);

U:10+random(90);

U:10+random(90);

Calculate

random

for i:1 thru 10 do pr...

Calculate

random

random(546);

Calculate

random-solve

A:random(10);

B:random(10);

eq1: A*x + B = 10;

Calculate

random

n: random(7)-2;

res: if n<2 then r...

Calculate

random

a2: random(5);

a1: random(8)*(random...

a0: random(6)*random(...

Calculate

random

lista[154, 182, 165, ...

lasku:lista[1+random(...

laskulista = [];

Calculate

random

random (1000);

random (1000);

random (1000);

Calculate

random

for i:1 thru 10 do pr...

Calculate