Generate random numbers that sum to a total with min/max bounds per part.
Project description
Random Sum Generator (RSG)
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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0781a6979c2c234f249f163e7119994e4656873d361650ad0715ad84df0d9971
|
|
| MD5 |
4a89c29a58f7176fee0e1922127ac6d9
|
|
| BLAKE2b-256 |
fe673d93b3440fe719e8ba172a33f82afd0b793f45560dc97c3bd31b85ca412a
|
File details
Details for the file random_sum_generator-0.2.1-py3-none-any.whl.
File metadata
- Download URL: random_sum_generator-0.2.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27f7531df5cc346d716f926369786b3c99e57b4bb219880789281e88d84ecb78
|
|
| MD5 |
430dc1a2105b706ef43e64829e1f4d52
|
|
| BLAKE2b-256 |
380307c49ee40756978c2ef4d85eb0796ab5610998ed3e48ccdee3d4d3e03e2f
|