Skip to main content

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

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:

  1. "desert" - desert island. A good LCG (linear congruential generator).
    • The seed must be between 1 and 2147483646 (inclusive)
  2. "randu" - bad LCG
    • The seed must be between 1 and 2147483647 (inclusive)

Example:
random_object = Random('desert', seed=10)

Discrete Distributions

  1. Bernoulli
    HomemadeRandom.bernoulli(p=0.5)
    Parameter: (optional) p: floats. 0 <= p <= 1. Probability of a success event

  2. Binomial
    HomemadeRandom.binomial(n, p)
    Parameter: n: int. n > 0. Total number of trials
    Parameter: p: floats. 0 <= p <= 1. Probability of a success event

  3. Geometric
    HomemadeRandom.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.

  4. Poisson
    HomemadeRandom.poisson(lmbda)
    Parameter: lmbda: floats. lmbda >= 0. Number of arrivals in one time unit

Continuous Distributions

  1. Uniform
    HomemadeRandom.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

  2. Exponential
    HomemadeRandom.exponential(lmbda)
    Parameter: lmbda: mean time between events

  3. Normal
    HomemadeRandom.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

  4. Gamma
    HomemadeRandom.gamma(alpha, beta)
    Parameter: alpha: floats. shape parameter
    Parameter: beta: floats. rate parameter

  5. Weibull
    HomemadeRandom.weibull(alpha, beta)
    Parameter: alpha: floats. shape parameter
    Parameter: beta: floats. scale parameter

  6. Triangular
    HomemadeRandom.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

[0.0.1] - 2020-11-30

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

HomemadeRandom-0.1.5.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

HomemadeRandom-0.1.5-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file HomemadeRandom-0.1.5.tar.gz.

File metadata

  • Download URL: HomemadeRandom-0.1.5.tar.gz
  • Upload date:
  • Size: 5.3 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

Hashes for HomemadeRandom-0.1.5.tar.gz
Algorithm Hash digest
SHA256 cecafe379c715deca03d00d09652f911bd33df1af04f4c613bde4f966c10eb55
MD5 940ba7fe1f96dd2b340c3c5751f69657
BLAKE2b-256 c1fc31d5f08bc8aca1519b14e9962e0ea2b191f62dd2e91ccaff58a4b652882c

See more details on using hashes here.

File details

Details for the file HomemadeRandom-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: HomemadeRandom-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 6.5 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

Hashes for HomemadeRandom-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ef6a9096466c1d850e14eed3712fdfde8a3890d75a0aa011f8424d9187b3a3ba
MD5 888d054f601f4208d87e8e862a35f557
BLAKE2b-256 412d036dfb77c7b9cda344b8e2e93b348778d483e416da33cbefd49c4923f6d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page