Statistics Methods

statistics.NormalDist.samples()

Generate n pseudorandom observations from a distribution. A seed can isolate the sequence for reproducible local examples; avoid relying on exact samples across versions.

Formal Syntax & Structure

python syntaxpython
distribution.samples(n, *, seed=None)

Parameters & Attributes

NameTypeDescription
nintNumber of samples to generate.
seedint, float, str, bytes, bytearray or NoneOptional pseudorandom seed; None uses default random initialization.

Return Value

list[float]

List of computed floating-point values.

Working Example

Example Snippetpython
import statisticsprint(len(statistics.NormalDist(5, 2).samples(4, seed=7)))
Python Reference