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:
RV = Random('desert', seed=10)

Discrete Distributions

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

  2. 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

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

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

Continuous Distributions

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

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

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

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

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

  6. 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.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.6.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: HomemadeRandom-0.1.6.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

Hashes for HomemadeRandom-0.1.6.tar.gz
Algorithm Hash digest
SHA256 e4fdb04bb4dad2cd97ff6d3582b6623b77377662b6931ca88f0e70609f49bb6e
MD5 f6dbecd03534f80465a6519a7600199f
BLAKE2b-256 897e4f39cde0f61c87cd95f742c2cdbfb38f794b7a03a908fe48c9fd7d92a162

See more details on using hashes here.

File details

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

File metadata

  • Download URL: HomemadeRandom-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 216ee60e92c6a5231993e7e450ae7b06d7a7912253ca5523a733f902a23d22e5
MD5 6ff717314896e1d388f1600e758d0843
BLAKE2b-256 f6dec6536a3b38e97b805c5e52ba8edecad51bc6fabeccdef37ffcf62414d931

See more details on using hashes here.

Supported by

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