Random Sampling
NLCPy random number routines produce pseudo random numbers and create sample from different statistical distributions.
Generator
The Generator provides access to a wide variety of probability distributions, and serves as a replacement for RandomState.
An easy example of Generator is below:
from nlcpy.random import Generator, MT19937
rng = Generator(MT19937(12345))
rng.standard_normal()
And, an easy example of using default_rng is below:
import nlcpy as vp
rng = vp.random.default_rng()
rng.standard_normal()
Available Functions and Methods
The following tables show that nlcpy.random.Generator class methods to generate random numbers.
Construct Generator
Constructs a new nlcpy.random.Generator with the default BitGenerator (MT19937). |
Simple Random Data
Returns random bytes. |
|
Returns random integers from low (inclusive) to high (exclusive), or if endpoint=True, low (inclusive) to high (inclusive). |
|
Returns random floats in the half-open interval |
Permutations
Randomly permutes a sequence, or returns a permuted range. |
|
Modifies a sequence in-place by shuffling its contents. |
Distributions
Draws samples from a binomial distribution. |
|
Draws samples from an exponential distribution. |
|
Draws samples from a Gamma distribution. |
|
Draws samples from a geometric distribution. |
|
Draws samples from a Gumbel distribution. |
|
Draws samples from a logistic distribution. |
|
Draws samples from a log-normal distribution. |
|
Draws random samples from a normal (Gaussian) distribution. |
|
Draws samples from a Poisson distribution. |
|
Draws samples from a standard Cauchy distribution with mode = 0. |
|
Draws samples from a standard exponential distribution. |
|
Draws samples from a standard Gamma distribution. |
|
Draws samples from a standard Normal distribution (mean=0, stdev=1). |
|
Draws samples from a uniform distribution. |
|
Draws samples from a Weibull distribution. |
RandomState
The RandomState provides access to legacy generators. An easy example of RandomState is below:
# Uses the nlcpy.random.RandomState
from nlcpy import random
random.standard_normal()
# or
rst = random.RandomState()
rst.standard_normal()
Available Functions and Methods
Seeding and State
Returns an ndarray representing the internal state of the generator. |
|
Reseeds a default bit generator(MT19937), which provide a stream of random bits. |
|
Sets the internal state of the generator from an ndarray. |
Simple Random Data
Returns random bytes. |
|
Random values in a given shape. |
|
Returns random integers from low (inclusive) to high (exclusive). |
|
Returns a sample (or samples) from the "standard normal" distribution. |
|
Returns random floats in the half-open interval |
|
Random integers of type nlcpy.int64/nlcpy.int32 between low and high, inclusive. |
|
Returns random floats in the half-open interval |
|
This is an alias of random_sample. |
|
This is an alias of random_sample. |
|
Random integers between 0 and |
Permutations
Randomly permutes a sequence, or returns a permuted range. |
|
Modifies a sequence in-place by shuffling its contents. |
Distributions
Draws samples from a binomial distribution. |
|
Draws samples from an exponential distribution. |
|
Draws samples from a Gamma distribution. |
|
Draws samples from a geometric distribution. |
|
Draws samples from a Gumbel distribution. |
|
Draws samples from a logistic distribution. |
|
Draws samples from a log-normal distribution. |
|
Draws random samples from a normal (Gaussian) distribution. |
|
Draws samples from a Poisson distribution. |
|
Draws samples from a standard Cauchy distribution with mode = 0. |
|
Draws samples from a standard exponential distribution. |
|
Draws samples from a standard Gamma distribution. |
|
Draws samples from a standard Normal distribution (mean=0, stdev=1). |
|
Draws samples from a uniform distribution. |
|
Draws samples from a Weibull distribution. |