Title: Theory / Unimportant / CS / Programming / Python / Lib / Random 9.6
Tags: hasNotNewEffectReturnsMeaning FromInstruction computer_to_instruction FromVariables
On every note of this deck, unless a note says otherwise:
Page: https://docs.python.org/3.6/library/random.html

Question: Python random library generate which kind of sequence
Answer: deterministic (thus unsuited for crypto)
Page: https://docs.python.org/3.6/library/random.html
Answer2: Using Mersenne twister

Question: How to create a subclass of random
Answer: override random, seed, getstate, setstate, everything else depend on these function
Page: https://docs.python.org/3.6/library/random.html
Context: Python
Answer2: override getrandbits to produce selections over an arbitrarily large range.

Instruction: random.seed()
Effect: Initialize the random number generator
Language: Python

Variable: a
Meaning: either the value of the seed, or a random source.
Page: https://docs.python.org/3.6/library/random.html
Context: random.seed()
Language: Python

Variable: version
Meaning: the version of the random generator
Page: https://docs.python.org/3.6/library/random.html
Context: random.seed()
Language: Python

Instruction: random.getstate()
Language: Python
Returns: An object capturing the current internal state of the generator. This object can be passed to setstate() to restore the state.

Instruction: random.setstate(foo)
Effect: restores the internal state of the generator to what it was at the time getstate() was called.
Language: Python
Assuming: foo should have been obtained from a previous call to getstate()

Instruction: random.getrandbits(foo)
Language: Python
Returns: a Python integer with foo random bits

Instruction: random.randrange(foos)
Effect: random.choice(range(foos))
Language: Python

Instruction: random.randint(a,b)
Language: Python
Returns: A random integer \(N\) such that \(a \le N \le b\).

Instruction: random.choice(seq)
Language: Python
Returns: random element from the non-empty sequence seq

Instruction: random.choices(population,k=1)
Language: Python
Returns: k elements, with replacement, from population

Variable: weights
Meaning: the weight to give to each element of the population
Page: https://docs.python.org/3.6/library/random.html
Context: random.choices(population,k=1)
Language: Python

Instruction: random.shuffle(seq)
Effect: Shuffle the sequence seq in place.
Language: Python

Instruction: random.sample(population,k)
Language: Python
Returns: k length list of unique elements chosen from the population.
Intuition: Used for random sampling without replacement.