A random generator for simulating human response times
Project description
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.
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
Built Distribution
Hashes for human_randgen-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4d76e096192a591a3aa9fb62385ddfcb63765f8817120266ab242933905b7b9 |
|
MD5 | f1f29613f7558e64b962e1dc2b7b72ed |
|
BLAKE2b-256 | 86ebabe318ba9bd74ca9b179836fdd71a1247512347f96816b111d239795a4b9 |