# probkit
Toolkit for modifying probabilities and shaping curves.
## Features
- **Tunable sigmoid curves** - Transform distributions with controllable steepness/flatness
- **Probability modification** - Scale probabilities using ratios with proper mathematical behavior
- **Pure functional design** - Deterministic functions for precise control
- **Random sampling** - Convenient random versions for generating samples from curves
- **Zero dependencies** - Only uses Python standard library
- **Robust validation** - Input validation and comprehensive error handling
- **Well tested** - Thoroughly unit tested with edge case coverage
## Quick Start
### Deterministic Functions
```python
from probkit import ntsig, biased_curve, modified_probability
# Sigmoid-like curve through (0,0), (0.5,0.5), (1,1)
y = ntsig(k=0.5, x=0.3) # k controls steepness
# Custom curve between any two points
y = biased_curve(k=0.2, a=10, b=100, x=0.7) # From (0,10) to (1,100)
# Modify probability with a ratio
new_prob = modified_probability(0.3, 1.5) # Scale 30% by 1.5x
new_prob = modified_probability(0.3, 3, 2) # Scale 30% by ratio 3/2
```
### Random Sampling
```python
import probkit.sampling
# Optionally set seed for reproducible results
sampling.seed(42)
# Sample from curves with random x values
sample = sampling.sample_ntsig(k=0.5)
sample = sampling.sample_biased_curve(k=0.2, a=10, b=100)
# Generate multiple samples
samples = [sampling.sample_ntsig(0.3) for _ in range(1000)]
```
## API Reference
### Curve Functions
- **`ntsig(k, x)`** - Normalized tunable sigmoid. Negative k is flat (logit-like), positive k is steep (sigmoid-like)
- **`nthsig(k, x)`** - Normalized tunable half-sigmoid. Negative k is convex, positive k is concave
- **`biased_curve(k, a, b, x)`** - Custom curve between points (0,a) and (1,b) with bias k
### Probability Functions
- **`modified_probability(k, a, b=None)`** - Scale probability by ratio `a` (or `a/b` if b provided) with proper saturation
### Random Sampling
- **`probkit.sampling.seed(value)`** - Set seed for reproducible random sampling
- **`probkit.sampling.sample_ntsig(k)`** - Sample from ntsig with random x
- **`probkit.sampling.sample_nthsig(k)`** - Sample from nthsig with random x
- **`probkit.sampling.sample_biased_curve(k, a, b)`** - Sample from biased_curve with random x
### Utilities
- **`clamp(val, min_val, max_val)`** - Constrain value to range
- **`transform_range(x, old_range, new_range)`** - Linear transformation between ranges
- **`effective_ratio(a, b)`** - Safe division with edge case handling
## Use Cases
- **Game development** - Procedural generation, difficulty curves, loot tables
- **Simulations** - Monte Carlo methods, statistical modeling
- **Data science** - Distribution transformation, probability weighting
- **Machine learning** - Custom activation functions, data preprocessing
## Install
Clone this repo or copy the `probkit` folder into your project. No external dependencies required.
```bash
# Example: install with pip from local folder
pip install .
```
## Testing
Run all tests with:
```bash
python -m unittest discover tests -v
```
## Contributing
Pull requests and suggestions welcome! Open an issue or PR on GitHub.
## License
MIT License. See LICENSE file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "probkit",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "probability, curves, sigmoid, mathematics, simulation, statistics",
"author": null,
"author_email": "Taylor Vance <mirrors.cities0w@icloud.com>",
"download_url": "https://files.pythonhosted.org/packages/a8/92/33d40c8a38cbd3727d5f88f8d988d61d8e1f999bc3db05744e1094f3a19b/probkit-0.1.3.tar.gz",
"platform": null,
"description": "# probkit\n\nToolkit for modifying probabilities and shaping curves.\n\n## Features\n- **Tunable sigmoid curves** - Transform distributions with controllable steepness/flatness\n- **Probability modification** - Scale probabilities using ratios with proper mathematical behavior\n- **Pure functional design** - Deterministic functions for precise control\n- **Random sampling** - Convenient random versions for generating samples from curves\n- **Zero dependencies** - Only uses Python standard library\n- **Robust validation** - Input validation and comprehensive error handling\n- **Well tested** - Thoroughly unit tested with edge case coverage\n\n## Quick Start\n\n### Deterministic Functions\n```python\nfrom probkit import ntsig, biased_curve, modified_probability\n\n# Sigmoid-like curve through (0,0), (0.5,0.5), (1,1)\ny = ntsig(k=0.5, x=0.3) # k controls steepness\n\n# Custom curve between any two points\ny = biased_curve(k=0.2, a=10, b=100, x=0.7) # From (0,10) to (1,100)\n\n# Modify probability with a ratio\nnew_prob = modified_probability(0.3, 1.5) # Scale 30% by 1.5x\nnew_prob = modified_probability(0.3, 3, 2) # Scale 30% by ratio 3/2\n```\n\n### Random Sampling\n```python\nimport probkit.sampling\n\n# Optionally set seed for reproducible results\nsampling.seed(42)\n\n# Sample from curves with random x values\nsample = sampling.sample_ntsig(k=0.5)\nsample = sampling.sample_biased_curve(k=0.2, a=10, b=100)\n\n# Generate multiple samples\nsamples = [sampling.sample_ntsig(0.3) for _ in range(1000)]\n```\n\n## API Reference\n\n### Curve Functions\n- **`ntsig(k, x)`** - Normalized tunable sigmoid. Negative k is flat (logit-like), positive k is steep (sigmoid-like)\n- **`nthsig(k, x)`** - Normalized tunable half-sigmoid. Negative k is convex, positive k is concave\n- **`biased_curve(k, a, b, x)`** - Custom curve between points (0,a) and (1,b) with bias k\n\n### Probability Functions \n- **`modified_probability(k, a, b=None)`** - Scale probability by ratio `a` (or `a/b` if b provided) with proper saturation\n\n### Random Sampling\n- **`probkit.sampling.seed(value)`** - Set seed for reproducible random sampling\n- **`probkit.sampling.sample_ntsig(k)`** - Sample from ntsig with random x\n- **`probkit.sampling.sample_nthsig(k)`** - Sample from nthsig with random x \n- **`probkit.sampling.sample_biased_curve(k, a, b)`** - Sample from biased_curve with random x\n\n### Utilities\n- **`clamp(val, min_val, max_val)`** - Constrain value to range\n- **`transform_range(x, old_range, new_range)`** - Linear transformation between ranges\n- **`effective_ratio(a, b)`** - Safe division with edge case handling\n\n## Use Cases\n- **Game development** - Procedural generation, difficulty curves, loot tables\n- **Simulations** - Monte Carlo methods, statistical modeling \n- **Data science** - Distribution transformation, probability weighting\n- **Machine learning** - Custom activation functions, data preprocessing\n\n## Install\nClone this repo or copy the `probkit` folder into your project. No external dependencies required.\n\n```bash\n# Example: install with pip from local folder\npip install .\n```\n\n## Testing\nRun all tests with:\n```bash\npython -m unittest discover tests -v\n```\n\n## Contributing\nPull requests and suggestions welcome! Open an issue or PR on GitHub.\n\n## License\nMIT License. See LICENSE file for details.\n",
"bugtrack_url": null,
"license": null,
"summary": "Toolkit for modifying probabilities and shaping curves.",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/taylorvance/probkit",
"Issues": "https://github.com/taylorvance/probkit/issues",
"Repository": "https://github.com/taylorvance/probkit"
},
"split_keywords": [
"probability",
" curves",
" sigmoid",
" mathematics",
" simulation",
" statistics"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d04b6cc5655d2e3463e3c51c2d05f550db642d81352b4046fa434512316a2b08",
"md5": "5c848c6a9b585d81e1d3ee5371215672",
"sha256": "c0429e79bb9787bc109dc6b0601a80a54a485ed758fa08092fc33a960cdcb743"
},
"downloads": -1,
"filename": "probkit-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5c848c6a9b585d81e1d3ee5371215672",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 6968,
"upload_time": "2025-08-15T02:09:12",
"upload_time_iso_8601": "2025-08-15T02:09:12.736470Z",
"url": "https://files.pythonhosted.org/packages/d0/4b/6cc5655d2e3463e3c51c2d05f550db642d81352b4046fa434512316a2b08/probkit-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a89233d40c8a38cbd3727d5f88f8d988d61d8e1f999bc3db05744e1094f3a19b",
"md5": "a4cfc561f66eb123c3fe891dd8388eb9",
"sha256": "3bcab74413162bf9256ff344a1b5a5a132ba157fcbace504778546a9c1387727"
},
"downloads": -1,
"filename": "probkit-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "a4cfc561f66eb123c3fe891dd8388eb9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 10197,
"upload_time": "2025-08-15T02:09:14",
"upload_time_iso_8601": "2025-08-15T02:09:14.014256Z",
"url": "https://files.pythonhosted.org/packages/a8/92/33d40c8a38cbd3727d5f88f8d988d61d8e1f999bc3db05744e1094f3a19b/probkit-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-15 02:09:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "taylorvance",
"github_project": "probkit",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "probkit"
}