Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

human_randgen-1.0.2.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.

human_randgen-1.0.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file human_randgen-1.0.2.tar.gz.

File metadata

  • Download URL: human_randgen-1.0.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for human_randgen-1.0.2.tar.gz
Algorithm Hash digest
SHA256 cc4e59feb5f9ab946aa4f8c218f8821e6654b7345a94e3a55de5b5e1d81bd041
MD5 fc3f109151c4ac8ff2ecd00c3312eab8
BLAKE2b-256 9e6d7c76380075bd64c284f5f13704c80e0ea64872ebd0275520d54b6fc6d445

See more details on using hashes here.

File details

Details for the file human_randgen-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: human_randgen-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for human_randgen-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c4d76e096192a591a3aa9fb62385ddfcb63765f8817120266ab242933905b7b9
MD5 f1f29613f7558e64b962e1dc2b7b72ed
BLAKE2b-256 86ebabe318ba9bd74ca9b179836fdd71a1247512347f96816b111d239795a4b9

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