The mt19937 Reference Manual

This is the mt19937 Reference Manual, version 1.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 17:23:33 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 mt19937

Portable MT19937 Mersenne Twister random number generator

Author

Douglas T. Crosher and Raymond Toy

License

Public domain

Version

1.1

Source

mt19937.asd.

Child Component

mt19937.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 mt19937/mt19937.asd

Source

mt19937.asd.

Parent Component

mt19937 (system).

ASDF Systems

mt19937.

Packages

mt19937-system.


3.1.2 mt19937/mt19937.lisp

Source

mt19937.asd.

Parent Component

mt19937 (system).

Packages

mt19937.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 mt19937-system

Source

mt19937.asd.

Use List
  • asdf/interface.
  • common-lisp.

4.2 mt19937

Source

mt19937.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *random-state*
Package

mt19937.

Source

mt19937.lisp.


5.1.2 Compiler macros

Compiler Macro: random (arg &optional state)
Package

mt19937.

Source

mt19937.lisp.


5.1.3 Ordinary functions

Function: %random-double-float (arg state)

Handle the single or double float case of RANDOM. We generate a float
in [0d0, 1d0) by clobbering the mantissa of 1d0 with random bits (52 bits); this yields a number in [1d0, 2d0). Then 1d0 is subtracted.

Package

mt19937.

Source

mt19937.lisp.

Function: %random-single-float (arg state)

Handle the single or double float case of RANDOM. We generate a float
in [0f0, 1f0) by clobbering the mantissa of 1f0 with random bits (23 bits); this yields a number in [1f0, 2f0). Then 1f0 is subtracted.

Package

mt19937.

Source

mt19937.lisp.

Function: init-random-state (&optional seed state)

Generate an random state vector from the given SEED. The seed can be either an integer or a vector of (unsigned-byte 32)

Package

mt19937.

Source

mt19937.lisp.

Function: make-random-state (&optional state)

Make a random state object. If STATE is not supplied, return a copy of the default random state. If STATE is a random state, then return a copy of STATE. If STATE is T then return a random state generated from the universal time. To make a random state from an integer seed, try “(make-random-object :state (init-random-state <seed>))”.

Package

mt19937.

Source

mt19937.lisp.

Function: random (arg &optional state)

Generates a uniformly distributed pseudo-random number greater than or equal to zero and less than Arg. State, if supplied, is the random state to use.

Package

mt19937.

Source

mt19937.lisp.

Function: random-chunk (state)
Package

mt19937.

Source

mt19937.lisp.

Function: random-state-p (object)
Package

mt19937.

Source

mt19937.lisp.


5.1.4 Structures

Structure: random-state
Package

mt19937.

Source

mt19937.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: state
Type

(simple-array (unsigned-byte 32) (627))

Initform

(mt19937:init-random-state)

Readers

random-state-state.

Writers

(setf random-state-state).


5.2 Internals


5.2.1 Constants

Constant: mt19937-b
Package

mt19937.

Source

mt19937.lisp.

Constant: mt19937-c
Package

mt19937.

Source

mt19937.lisp.

Constant: mt19937-lower-mask
Package

mt19937.

Source

mt19937.lisp.

Constant: mt19937-m
Package

mt19937.

Source

mt19937.lisp.

Constant: mt19937-n
Package

mt19937.

Source

mt19937.lisp.

Constant: mt19937-upper-mask
Package

mt19937.

Source

mt19937.lisp.

Constant: random-chunk-length
Package

mt19937.

Source

mt19937.lisp.


5.2.2 Ordinary functions

Function: %random-integer (arg state)

Generates an integer greater than or equal to zero and less than Arg. Successive chunks are concatenated without overlap to construct integers larger than a single chunk. The return value has this property:
If two integers are generated from the same state with Arg equal to 2^m and 2^n, respectively, then bit k is the same in both integers for 0 <= k < min(m,n). Each call to %RANDOM-INTEGER consumes at least one chunk; bits left over from previous chunks are not re-used.

Package

mt19937.

Source

mt19937.lisp.

Function: copy-random-state (instance)
Package

mt19937.

Source

mt19937.lisp.

Function: generate-seed ()
Package

mt19937.

Source

mt19937.lisp.

Function: int-init-random-state (&optional seed state)
Package

mt19937.

Source

mt19937.lisp.

Function: make-random-object (&key state)
Package

mt19937.

Source

mt19937.lisp.

Function: random-mt19937-update (state)
Package

mt19937.

Source

mt19937.lisp.

Reader: random-state-state (instance)
Writer: (setf random-state-state) (instance)
Package

mt19937.

Source

mt19937.lisp.

Target Slot

state.

Function: vec-init-random-state (key &optional state)
Package

mt19937.

Source

mt19937.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   %   (  
C   F   G   I   M   R   V  
Index Entry  Section

%
%random-double-float: Public ordinary functions
%random-integer: Private ordinary functions
%random-single-float: Public ordinary functions

(
(setf random-state-state): Private ordinary functions

C
Compiler Macro, random: Public compiler macros
copy-random-state: Private ordinary functions

F
Function, %random-double-float: Public ordinary functions
Function, %random-integer: Private ordinary functions
Function, %random-single-float: Public ordinary functions
Function, (setf random-state-state): Private ordinary functions
Function, copy-random-state: Private ordinary functions
Function, generate-seed: Private ordinary functions
Function, init-random-state: Public ordinary functions
Function, int-init-random-state: Private ordinary functions
Function, make-random-object: Private ordinary functions
Function, make-random-state: Public ordinary functions
Function, random: Public ordinary functions
Function, random-chunk: Public ordinary functions
Function, random-mt19937-update: Private ordinary functions
Function, random-state-p: Public ordinary functions
Function, random-state-state: Private ordinary functions
Function, vec-init-random-state: Private ordinary functions

G
generate-seed: Private ordinary functions

I
init-random-state: Public ordinary functions
int-init-random-state: Private ordinary functions

M
make-random-object: Private ordinary functions
make-random-state: Public ordinary functions

R
random: Public compiler macros
random: Public ordinary functions
random-chunk: Public ordinary functions
random-mt19937-update: Private ordinary functions
random-state-p: Public ordinary functions
random-state-state: Private ordinary functions

V
vec-init-random-state: Private ordinary functions