Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2023-03-01 17:54:42
Size: 1552
Comment:
Revision 3 as of 2023-06-15 18:38:52
Size: 1689
Comment:
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
== BetaVariate == == Usage ==

=
== BetaVariate ===
Line 15: Line 17:
== Choice == === Choice ===
Line 21: Line 23:
== Choices == === Choices ===
Line 27: Line 29:
== ExpoVariate == === ExpoVariate ===
Line 33: Line 35:
== GammaVariate == === GammaVariate ===
Line 39: Line 41:
== Gauss == === Gauss ===
Line 53: Line 55:
== GetRandBits == === GetRandBits ===
Line 59: Line 61:
== LogNormVariate == === LogNormVariate ===
Line 65: Line 67:
== NormalVariate == === NormalVariate ===
Line 79: Line 81:
== ParetoVariate == === ParetoVariate ===
Line 85: Line 87:
== RandBytes == === RandBytes ===
Line 91: Line 93:
== RandInt == === RandInt ===
Line 97: Line 99:
== Random == === Random ===
Line 111: Line 113:
== RandRange == === RandRange ===
Line 117: Line 119:
== Sample == === Sample ===
Line 123: Line 125:
== Seed == === Seed ===
Line 129: Line 131:
== Shuffle == === Shuffle ===
Line 135: Line 137:
== Triangular == === Triangular ===
Line 141: Line 143:
== Uniform == === Uniform ===
Line 157: Line 159:
== VonMisesVariate == === VonMisesVariate ===
Line 163: Line 165:
== WeibullVariate == === WeibullVariate ===
Line 173: Line 175:
[[https://pymotw.com/3/random/|Python Module of the Day article for random]]

Python Random


Usage

BetaVariate


Choice


Choices


ExpoVariate


GammaVariate


Gauss

Returns a pseudo-random float from a Gaussian distribution characterized by mu and sigma (in that order).

import random

r = random.gauss(0, 1)


GetRandBits


LogNormVariate


NormalVariate

Returns a pseudo-random float from a normal distribution characterized by mu and sigma (in that order).

import random

r = random.normalvariate(0, 1)


ParetoVariate


RandBytes


RandInt


Random

Returns a pseudo-random float between 0 and 1, inclusive of 0.

import random

r = random.random()


RandRange


Sample


Seed


Shuffle


Triangular


Uniform

Returns a pseudo-random float between a and b, inclusive.

import random

r = random.uniform(0,1)

Note: due to floating point rounding, it is possible that the high end of the range will not be included.


VonMisesVariate


WeibullVariate


See also

Python random module documentation

Python Module of the Day article for random


CategoryRicottone

Python/Random (last edited 2023-12-09 01:48:58 by DominicRicottone)