Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arose13/rosey-sim
little package for very basic sensitivity analysis
https://github.com/arose13/rosey-sim
Last synced: 12 days ago
JSON representation
little package for very basic sensitivity analysis
- Host: GitHub
- URL: https://github.com/arose13/rosey-sim
- Owner: arose13
- Created: 2020-06-17T01:52:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-17T14:58:10.000Z (over 4 years ago)
- Last Synced: 2024-11-29T15:54:02.922Z (29 days ago)
- Language: Python
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rosey-sim
Causal, Probabilistic and Uncertainty Simulations## Installation
```bash
pip install rosey-sim
```## Example
```python
from rosey_sim.sensitivity import Model, Parameter
from tqdm import trange
import matplotlib.pyplot as graph
import seaborn as sns# Specify function
def profit_func(price, cost):
return price - cost# Specify model (NOTE the parameters matches the functions arguments)
profit_model = Model(
profit_func,
params=[
Parameter('cost', [3, 7]),
Parameter('price', [10, 12])
]
)# Single sample
print(f'${profit_model.sample():.2f}')# Many single samples
trace = [profit_model.sample() for _ in trange(10000)]
sns.distplot(trace, label='One at a time')# Many sample immediately
trace = profit_model.sample(10000)
sns.distplot(trace, label='All at once')
graph.show()# Even nesting is allowed
def random_divide(profit_func, denom):
return profit_func / denomfinal_model = Model(
random_divide,
params=[
profit_model,
Parameter('denom', [3, 4])
]
)
print(final_model.sample())
```