Human Random Number Generator
This is a simple package which makes it easy to generate random numbers with a distribution following human response times. It is possible to fine-tune the generator with existing data (e.g., time between mouse clicks).
Installation
pip install human_randgen
Usage
Initialize the generator with your choice of mode and standard deviation. These parameters depend on your use case. For example, if you are simulating a person clicking a mouse every 2 +- 1 seconds, you could try:
from human_randgen.model import HumanRng
rng = HumanRng(mode=2, sigma=1)
Generate random numbers using the rand(num_samples=1) function:
rng.rand()
Finally, update the generator with existing data with the fit function:
rng.fit([2.2, 1.8, 5.4, 2.1])
This is useful if you are not sure what the mode and standard deviation should be during initialization.
Calling the fit function will update the mode and standard deviation based on the data, and all following calls to rand will use the updated parameters. In addition, the updated values will be printed out to console. You can save them to reinitialize the generator with the fitted parameters from the onset.
The fit function can be called as many times as you want. The more data you pass to this function, the less influence your choice of initialization parameters will have.
Internals
The underlying distribution is lognormal, which is said to represent many human behaviors. During initialization, Newton's method is used to calculate the mean and variance of the lognormal distribution from the given parameters.
For fitting, we add a normal-inverse-gamma distribution as the conjugate prior on the parameters and perform MAP estimation.
Release files for human-randgen 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| human_randgen-1.0.2.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| human_randgen-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.3 kB
Release files / human_randgen-1.0.2.tar.gz
| Download URL | human_randgen-1.0.2.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc4e59feb5f9ab946aa4f8c218f8821e6654b7345a94e3a55de5b5e1d81bd041
|
|
BLAKE2b-256 checksum How to use checksums |
9e6d7c76380075bd64c284f5f13704c80e0ea64872ebd0275520d54b6fc6d445
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / human_randgen-1.0.2-py3-none-any.whl
| Download URL | human_randgen-1.0.2-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c4d76e096192a591a3aa9fb62385ddfcb63765f8817120266ab242933905b7b9
|
|
BLAKE2b-256 checksum How to use checksums |
86ebabe318ba9bd74ca9b179836fdd71a1247512347f96816b111d239795a4b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|