Skip to main content

Generate random numbers that sum to a total with min/max bounds per part.

Project description

Random Sum Generator (RSG)

Launch Streamlit

A hybrid Python module + Streamlit app that generates random integers or floats summing to a target value — with per-part constraints and visual output.


📦 Install from PyPI (coming soon)

pip install random_sum_generator

🧪 Example Usage

from random_sum_generator import RandomSumGenerator

gen = RandomSumGenerator()
print(gen.generate(total=100, parts=4, min_val=5, max_val=30, mode='int'))
print(gen.generate(100, 4, min_val=[10, 0, 5, 15], max_val=[30, 50, 25, 40], mode='float'))

🌐 Run the Streamlit App Locally

streamlit run streamlit_app.py

💡 Features

  • Integer or float output
  • Exact sum guarantee
  • Per-part min/max control
  • Safe resampling
  • Debug logging

⚠️ Bound Constraints — Important Notes

To ensure generation is possible, these conditions must be met:

  • parts * min_val ≤ total ≤ parts * max_val
  • It's recommended that max_val > total / parts
  • Very tight max values (like max_val = total / parts) will likely fail due to rounding and scaling

Example of what might fail:

gen.generate(total=100, parts=4, min_val=5, max_val=25)  # may fail due to tight upper bound

To fix:

gen.generate(total=100, parts=4, min_val=5, max_val=27)  # allows more flexibility

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

random_sum_generator-0.2.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

random_sum_generator-0.2.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file random_sum_generator-0.2.1.tar.gz.

File metadata

  • Download URL: random_sum_generator-0.2.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for random_sum_generator-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0781a6979c2c234f249f163e7119994e4656873d361650ad0715ad84df0d9971
MD5 4a89c29a58f7176fee0e1922127ac6d9
BLAKE2b-256 fe673d93b3440fe719e8ba172a33f82afd0b793f45560dc97c3bd31b85ca412a

See more details on using hashes here.

File details

Details for the file random_sum_generator-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for random_sum_generator-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 27f7531df5cc346d716f926369786b3c99e57b4bb219880789281e88d84ecb78
MD5 430dc1a2105b706ef43e64829e1f4d52
BLAKE2b-256 380307c49ee40756978c2ef4d85eb0796ab5610998ed3e48ccdee3d4d3e03e2f

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