The random-sample Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The random-sample Reference Manual

This is the random-sample Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 04:31:02 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Random-Sample is a Lisp library for something which is not nearly as simple as it sounds: reliably taking a random sample of a sequence.

Most of the time you will just use random-sample:

(random-sample:random-sample (iota 100) 5)
=> (57 32 28 45 4)

The algorithm used for sampling without replacement is basically Vitter’s Algorithm D.

Sometimes you may want to use the algorithm at a lower level. You don’t want the sample itself; you only want the indices. In this case, you can directly use map-random-below, which simply calls a provided function on each index.

(map-random-below my-function 5 length)

Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

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


Previous: , Up: Systems   [Contents][Index]

2.1 random-sample

Author

Paul M. Rodriguez <pmr@ruricolist.com>

License

MIT

Description

Random sample of a sequence with uniform distribution.

Dependencies
Source

random-sample.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

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


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 random-sample.asd

Location

random-sample.asd

Systems

random-sample (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 random-sample/package.lisp

Parent

random-sample (system)

Location

package.lisp

Packages

random-sample


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 random-sample/readtable.lisp

Dependency

package.lisp (file)

Parent

random-sample (system)

Location

readtable.lisp


Previous: , Up: Lisp files   [Contents][Index]

3.1.4 random-sample/random-sample.lisp

Dependency

readtable.lisp (file)

Parent

random-sample (system)

Location

random-sample.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 random-sample

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

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


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Functions

Function: generate-index-array N LEN
Package

random-sample

Source

random-sample.lisp (file)

Function: map-random-below FN N LEN

Generate N random indices for a sequence of length LEN, in ascending order, calling FN on each index as it is generated.

Package

random-sample

Source

random-sample.lisp (file)

Function: random-sample SEQ N &key WITH-REPLACEMENT

Return a random sample of SEQ of size N.

If WITH-REPLACEMENT is true, return a random sample with replacement (a "draw").

If WITH-REPLACEMENT is false, return a random sample without replacement (a "deal").

Package

random-sample

Source

random-sample.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Constants

Constant: +storage-for-deflex-var-alpha+

The parameter that decides whether to use method A or method D.

Package

random-sample

Source

random-sample.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Symbol macros

Symbol Macro: alpha
Package

random-sample

Source

random-sample.lisp (file)

Expansion

random-sample::+storage-for-deflex-var-alpha+


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Functions

Function: collect-sample SEQ INDEX-ARRAY
Package

random-sample

Source

random-sample.lisp (file)

Function: generate-index-array/replacement N LEN
Package

random-sample

Source

random-sample.lisp (file)

Function: make-index-array N
Package

random-sample

Source

random-sample.lisp (file)

Function: uniformrv ()
Package

random-sample

Source

random-sample.lisp (file)

Function: vitter-method-a FN N n

Vitter’s Method A.

Mostly faithful to Vitter’s Pascal code, but uses advanced Common Lisp features like exponents and subtraction.

Package

random-sample

Source

random-sample.lisp (file)

Function: vitter-method-d FN N n

Vitter’s Method D.

Package

random-sample

Source

random-sample.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.4 Types

Type: index-array ()
Package

random-sample

Source

random-sample.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   R  
Index Entry  Section

F
File, Lisp, random-sample.asd: The random-sample<dot>asd file
File, Lisp, random-sample/package.lisp: The random-sample/package<dot>lisp file
File, Lisp, random-sample/random-sample.lisp: The random-sample/random-sample<dot>lisp file
File, Lisp, random-sample/readtable.lisp: The random-sample/readtable<dot>lisp file

L
Lisp File, random-sample.asd: The random-sample<dot>asd file
Lisp File, random-sample/package.lisp: The random-sample/package<dot>lisp file
Lisp File, random-sample/random-sample.lisp: The random-sample/random-sample<dot>lisp file
Lisp File, random-sample/readtable.lisp: The random-sample/readtable<dot>lisp file

R
random-sample.asd: The random-sample<dot>asd file
random-sample/package.lisp: The random-sample/package<dot>lisp file
random-sample/random-sample.lisp: The random-sample/random-sample<dot>lisp file
random-sample/readtable.lisp: The random-sample/readtable<dot>lisp file

Jump to:   F   L   R  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   C   F   G   M   R   U   V  
Index Entry  Section

C
collect-sample: Internal functions

F
Function, collect-sample: Internal functions
Function, generate-index-array: Exported functions
Function, generate-index-array/replacement: Internal functions
Function, make-index-array: Internal functions
Function, map-random-below: Exported functions
Function, random-sample: Exported functions
Function, uniformrv: Internal functions
Function, vitter-method-a: Internal functions
Function, vitter-method-d: Internal functions

G
generate-index-array: Exported functions
generate-index-array/replacement: Internal functions

M
make-index-array: Internal functions
map-random-below: Exported functions

R
random-sample: Exported functions

U
uniformrv: Internal functions

V
vitter-method-a: Internal functions
vitter-method-d: Internal functions

Jump to:   C   F   G   M   R   U   V  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   +  
A   C   S  
Index Entry  Section

+
+storage-for-deflex-var-alpha+: Internal constants

A
alpha: Internal symbol macros

C
Constant, +storage-for-deflex-var-alpha+: Internal constants

S
Symbol Macro, alpha: Internal symbol macros

Jump to:   +  
A   C   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   I   P   R   S   T  
Index Entry  Section

I
index-array: Internal types

P
Package, random-sample: The random-sample package

R
random-sample: The random-sample system
random-sample: The random-sample package

S
System, random-sample: The random-sample system

T
Type, index-array: Internal types

Jump to:   I   P   R   S   T