Skip to main content

Generate random vectors whose components sum up to one

Project description

Generate random vectors whose components sum up to one

This Python3 module implements different approaches [1] to randomly and uniformly generate d-dimensional vectors whose components sum up to one.

[1] Maziero, J. Generating Pseudo-Random Discrete Probability Distributions. Brazilian Journal of Physics 45, 377–382 (2015).


Run the following to install the module:

pip install pyrandvec


from pyrandvec import sample

# Generate 10 4-dimensional vectors with the simplex-method
sample(10, 4, method = 'simplex')

# Generate 10 3-dimensional vectors with the trigonometric methdod with subsequent shuffling
sample(10, 3, method = 'trigonometric', shuffle = True)

Developing randvec

To install the pyrandvec module along with the tools you need to develop and run test, run the following command in your virtual environment (virtualenv):

pip install -e .[dev]

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

pyrandvec-1.0.1.tar.gz (4.7 kB view hashes)

Uploaded source

Built Distribution

pyrandvec-1.0.1-py3-none-any.whl (4.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page