Skip to main content

A random number generator with custom probability distribution

Project description

RandDist

python random generator with custom probability distribution

This minimal package generates a list of int or float numbers within a specific range and steps with custom probability distribution.

myfile

How to use

install

pip install randdist

include

import randdist

generate

numbers_list, sample_number = randdist.randint(0, 10, formula = lambda x:x**2)

Methods

  • randint: Generates integer numbers
  • randfloat: Generates float numbers

Parameters

  • min_value: start
  • max_value: stop
  • step: bin step size default = 1
  • formula: lambda function for distribution curve default = lambda x:x
  • seeds: # of generated numbers default = 1000

Outputs

  • list: a list of shuffled generated numbers
  • sample: picks one from the list

Demo

  • min_value = -3
  • max_value = 3
  • step = 0.5
  • formula = lambda x:12-(x**2)
  • seeds = 1000
# generate int numbers
random_list_int, sample_int = randdist.randint(min_value, max_value, step, formula, seeds)

# generate float numbers
random_list_float, sample_float = randdist.randfloat(min_value, max_value+step, step, formula, seeds)

myfile myfile myfile

Test Distribution

with 10K generated numbers

# pick samples from 10K generated list of numbers
generated_list = []
for i in range(10000):
    _, sample_int = randdist.randint(-3, 3, 0.5, lambda x:12-(x**2))
    generated_list.append(sample_int)

myfile

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

RandDist-0.0.4.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

RandDist-0.0.4-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file RandDist-0.0.4.tar.gz.

File metadata

  • Download URL: RandDist-0.0.4.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for RandDist-0.0.4.tar.gz
Algorithm Hash digest
SHA256 e628d550871dc18616fdf21e997bdade86c20658c94515b3ecc597e6302278da
MD5 bacd11b015d9974175980c58b176a93a
BLAKE2b-256 a995b369f778bb993ea9c5c1e3e2fe1a4ceb170b6372e37c72eed516bcb0a2b4

See more details on using hashes here.

File details

Details for the file RandDist-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: RandDist-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for RandDist-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 80d02312b7f409c673ff96ce285fc0169ec88e4a88737dbc63be8536eb329912
MD5 4d2f4d70a2ac8687f1659a2195fd9f39
BLAKE2b-256 3aa6e9a75667580d6c77a9466766cafcf415b7f2d95e7a67753b01e11c52dfe2

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