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.
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 numbersrandfloat
: Generates float numbers
Parameters
min_value
: startmax_value
: stopstep
: bin step sizedefault = 1
formula
: lambda function for distribution curvedefault = lambda x:x
seeds
: # of generated numbersdefault = 1000
Outputs
list
: a list of shuffled generated numberssample
: 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)
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)
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
RandDist-0.0.4.tar.gz
(3.7 kB
view hashes)