A random number generator built from scratch for ISYE6644 class project
Project description
Random Variate Generator
This package provides access to a few frequently used discrete and continuous distributions.
Installation
Normal Installation
The library is uploaded to PyPI: https://pypi.org/project/HomemadeRandom/
pip install HomemadeRandom
API Details and Examples
Start using the library by running
from HomemadeRandom import Random
Initialize a HomemadeRandom object with two parameters: type of base random number generator and a seed.
Select a base random number generator from the following:
- "desert" - desert island. A good LCG (linear congruential generator).
- The seed must be between 1 and 2147483646 (inclusive)
- "randu" - bad LCG
- The seed must be between 1 and 2147483647 (inclusive)
Example:
RV = Random('desert', seed=10)
Discrete Distributions
-
Bernoulli
RV.bernoulli(p=0.5)
Parameter: (optional) p: floats. 0 <= p <= 1. Probability of a success event -
Binomial
RV.binomial(n, p)
Parameter: n: int. n > 0. Total number of trials
Parameter: p: floats. 0 <= p <= 1. Probability of a success event -
Geometric
RV.geometric(p, mode=0)
Parameter: p: floats. 0 <= p <= 1. Probability of a success event
Parameter: (optional) mode: int. Mode 0 is the fast and direct way. Any other mode will use the other implementation, which was implemented for academic purpose. -
Poisson
RV.poisson(lmbda)
Parameter: lmbda: floats. lmbda >= 0. Number of arrivals in one time unit
Continuous Distributions
-
Uniform
RV.uniform(a=0, b=1)
Parameter: (optional) a: floats. lower bound of uniform distribution, inclusive
Parameter: (optional) b: floats. upper bound of uniform distribution, exclusive -
Exponential
RV.exponential(lmbda)
Parameter: lmbda: mean time between events -
Normal
RV.normal(mu=0, sigma=1.0)
Parameter: (optional) mu: floats. mean of a normal distribution Parameter: (optional) sigma: floats. standard deviation of a normal distribution -
Gamma
RV.gamma(alpha, beta)
Parameter: alpha: floats. shape parameter
Parameter: beta: floats. rate parameter -
Weibull
RV.weibull(alpha, beta)
Parameter: alpha: floats. shape parameter
Parameter: beta: floats. scale parameter -
Triangular
RV.triangular(low=0.0, high=1.0, mode=None)
Parameter: low: floats. lower limit
Parameter: high: floats. upper limit
Parameter: mode: floats. number with highest probability where a <= c <= b
See tests/test.py
for actual usage or
download/clone the project and execute python test.py
inside the tests directory
[0.1.7] - 2020-11-29 [0.0.0] - 2020-11-29
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file HomemadeRandom-0.1.7.tar.gz
.
File metadata
- Download URL: HomemadeRandom-0.1.7.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94f4f853ad9a9f759afc9d2d4c165c8592cf041dcfb2876d9f1be817ca77de34 |
|
MD5 | fdb0c0cc8f43e6e5aefbb216aaabf3cb |
|
BLAKE2b-256 | fea2cc9ce98640b24d4f2b28860d06e3248df264ff6dde3525b9299dd5bba2d7 |
File details
Details for the file HomemadeRandom-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: HomemadeRandom-0.1.7-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 103788f3c9eed19afc6e37a1fb6e2293658357cb6c3061debbbd2d9e70bbee40 |
|
MD5 | ab9db0d7bf649aa6af48a139714cb1c0 |
|
BLAKE2b-256 | 4b9cf4b0d128a8547cad80242e7db6c79d38df33afb60c8af8a36376710ef1e7 |