Random generator with custom distribution function

RandDist

One day, I was tasked with creating a synthetic dataset of electricity consumption for a large number of houses over a long period of time to complement a real dataset. I realized that a normal distribution wouldn’t work, so I couldn’t use numpy.random.normal. We eventually didn’t use the synthetic dataset in our final work, but I had a neat class that was ready to be packaged as a pip package at the end of the day. I’d never made a pip package before, so I did some research and figured it out. It’s pretty straightforward. So, here it is. RandDist - a random generator with custom distribution function.

Simply install it using pip:

pip install randdist

Import it in your code with:

import randdist

Generate:

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

It has two methods: randint and randfloat. You can use either of them to generate either integer or float numbers. You can specify the range of the numbers to be generated, the step size (default is 1), and most importantly, the custom probability distribution function using a lambda function.

I’ve included a brief documentation on the repo’s page:

🔁 Github Repo

Pull requests are always welcome!