# 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

 `nlcpy.random.default_rng` Constructs a new nlcpy.random.Generator with the default BitGenerator (MT19937).

### Simple Random Data

 `nlcpy.random.Generator.bytes` Returns random bytes. `nlcpy.random.Generator.integers` Returns random integers from low (inclusive) to high (exclusive), or if endpoint=True, low (inclusive) to high (inclusive). `nlcpy.random.Generator.random` Returns random floats in the half-open interval `[0.0, 1.0)`.

### Permutations

 `nlcpy.random.Generator.permutation` Randomly permutes a sequence, or returns a permuted range. `nlcpy.random.Generator.shuffle` Modifies a sequence in-place by shuffling its contents.

### Distributions

 `nlcpy.random.Generator.binomial` Draws samples from a binomial distribution. `nlcpy.random.Generator.exponential` Draws samples from an exponential distribution. `nlcpy.random.Generator.gamma` Draws samples from a Gamma distribution. `nlcpy.random.Generator.geometric` Draws samples from a geometric distribution. `nlcpy.random.Generator.gumbel` Draws samples from a Gumbel distribution. `nlcpy.random.Generator.logistic` Draws samples from a logistic distribution. `nlcpy.random.Generator.lognormal` Draws samples from a log-normal distribution. `nlcpy.random.Generator.normal` Draws random samples from a normal (Gaussian) distribution. `nlcpy.random.Generator.poisson` Draws samples from a Poisson distribution. `nlcpy.random.Generator.standard_cauchy` Draws samples from a standard Cauchy distribution with mode = 0. `nlcpy.random.Generator.standard_exponential` Draws samples from a standard exponential distribution. `nlcpy.random.Generator.standard_gamma` Draws samples from a standard Gamma distribution. `nlcpy.random.Generator.standard_normal` Draws samples from a standard Normal distribution (mean=0, stdev=1). `nlcpy.random.Generator.uniform` Draws samples from a uniform distribution. `nlcpy.random.Generator.weibull` 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

 `nlcpy.random.RandomState.get_state` Returns an ndarray representing the internal state of the generator. `nlcpy.random.RandomState.seed` Reseeds a default bit generator(MT19937), which provide a stream of random bits. `nlcpy.random.RandomState.set_state` Sets the internal state of the generator from an ndarray.

### Simple Random Data

 `nlcpy.random.RandomState.bytes` Returns random bytes. `nlcpy.random.RandomState.rand` Random values in a given shape. `nlcpy.random.RandomState.randint` Returns random integers from low (inclusive) to high (exclusive). `nlcpy.random.RandomState.randn` Returns a sample (or samples) from the "standard normal" distribution. `nlcpy.random.RandomState.random` Returns random floats in the half-open interval `[0.0, 1.0)`. `nlcpy.random.RandomState.random_integers` Random integers of type nlcpy.int64/nlcpy.int32 between low and high, inclusive. `nlcpy.random.RandomState.random_sample` Returns random floats in the half-open interval `[0.0, 1.0)`. `nlcpy.random.RandomState.ranf` This is an alias of random_sample. `nlcpy.random.RandomState.sample` This is an alias of random_sample. `nlcpy.random.RandomState.tomaxint` Random integers between 0 and `nlcpy.iinfo(nlcpy.int_).max`, inclusive.

### Permutations

 `nlcpy.random.RandomState.permutation` Randomly permutes a sequence, or returns a permuted range. `nlcpy.random.RandomState.shuffle` Modifies a sequence in-place by shuffling its contents.

### Distributions

 `nlcpy.random.RandomState.binomial` Draws samples from a binomial distribution. `nlcpy.random.RandomState.exponential` Draws samples from an exponential distribution. `nlcpy.random.RandomState.gamma` Draws samples from a Gamma distribution. `nlcpy.random.RandomState.geometric` Draws samples from a geometric distribution. `nlcpy.random.RandomState.gumbel` Draws samples from a Gumbel distribution. `nlcpy.random.RandomState.logistic` Draws samples from a logistic distribution. `nlcpy.random.RandomState.lognormal` Draws samples from a log-normal distribution. `nlcpy.random.RandomState.normal` Draws random samples from a normal (Gaussian) distribution. `nlcpy.random.RandomState.poisson` Draws samples from a Poisson distribution. `nlcpy.random.RandomState.standard_cauchy` Draws samples from a standard Cauchy distribution with mode = 0. `nlcpy.random.RandomState.standard_exponential` Draws samples from a standard exponential distribution. `nlcpy.random.RandomState.standard_gamma` Draws samples from a standard Gamma distribution. `nlcpy.random.RandomState.standard_normal` Draws samples from a standard Normal distribution (mean=0, stdev=1). `nlcpy.random.RandomState.uniform` Draws samples from a uniform distribution. `nlcpy.random.RandomState.weibull` Draws samples from a Weibull distribution.