Case generator, optimizer, and summarizer for models.
Project description
CASEGEN MC
Probe a model and see the possibilities. Takes model and input dictionary and evaluates cases to explore the model space using grids, random sampling, and optimization techniques.
The input dictionary is defined by the user with mean value, uncertainty, uncertainty distribution, range, and bounds. Sparse definition okay and assumes 0 unc and range by default. Numerical and categorical parameters are supported.
Includes matplotlib utility functions for standard plotting.
| Analysis Type | Description |
|---|---|
estimate |
Runs the model with the mean values of the input parameters. |
estimate_with_unc |
Runs the model with sampled input parameters based on their uncertainty distributions. |
estimate_with_unc_combos |
Runs the model with combinations of extreme values of the input parameters. |
sensitivity_analysis_unc |
Performs sensitivity analysis by varying each parameter individually based on its uncertainty distribution. |
sensitivity_analysis_range |
Performs sensitivity analysis by varying each parameter individually over its entire range. |
sensitivity_analysis_2D |
Performs 2D sensitivity analysis by varying two parameters simultaneously over a grid. |
regular_grid |
Runs the model over a regular grid of input parameter values. |
random_uniform_grid |
Runs the model over a grid of randomly sampled input |
Install
pip install casegenmc
Use
import casegenmc as cgm
# Define model
def model(x):
out = {}
out["y0"] = x["x0"]**2 + np.exp(x["x1"]) + x['x3']
out["y1"] = x["x0"] + x["x1"] + x["x2"] + x["x3"]
return out
# Create input stack. some parameters fixed - don't have uncertainty or range of options.
# mean, unc, range, bounds (minimum and maximum value), unc_type
input_stack = {
"x0": {"mean": 1., "unc": .2, 'range': [0, 5], 'bounds': [0, 100], 'unc_type': 'normal'},
"x1": {"mean": 1., "unc": .2, 'range': [0, 3], 'unc_type': 'lognormal'},
"x2": 3.,
"x3": 4,
"x4": {"mean": "a", 'range': ["a", "b"], "options": ["a", "b", "c"], "unc_type": "choice", },
}
# Pre-process input stack
input_stack = cgm.process_input_stack(input_stack)
print(input_stack)
# Evaluate the model with the input_stack.
cgm.run_analysis(model=model, input_stack=input_stack, analyses=["estimate"])
# Estimate with uncertainty.
cgm.run_analysis(model, input_stack, n_samples=1000, analyses=["estimate_with_unc"], par_output="y0")
# Estimate with uncertainty combinations.
cgm.run_analysis(model, input_stack, n_samples=1000, analyses=["estimate_with_unc_combos"], par_output="y0")
# 2d sensitivity analysis and analysis w.r.t 1 output parameter.
cgm.run_analysis(model, input_stack, n_samples=1000, analyses=["sensitivity_analysis_2D"], par_grid_xy=["x0", "x1"], par_output="y0")
# sample a regular grid defined by range.
cgm.run_analysis(model, input_stack, n_samples=1000, analyses=["regular_grid"], par_output="y0")
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 casegenmc-0.1.0.tar.gz.
File metadata
- Download URL: casegenmc-0.1.0.tar.gz
- Upload date:
- Size: 26.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49fb391ddc218d16059adad17391e624a35e6d6b4efb4c535dfd47fd113d1aa1
|
|
| MD5 |
a3c8195682102fd802ef0639955a2ab5
|
|
| BLAKE2b-256 |
1ef8c4c710c0b42b7177d569c710b7eed52455db98d65f4be67fc5755d681061
|
File details
Details for the file casegenmc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: casegenmc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 28.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d74300e4f0aecba12e569b36b6b2e750fdb114e36dc2289acd385321910dc0f6
|
|
| MD5 |
2f1d2cf9c9b834b3d97fbdb0c46a70ad
|
|
| BLAKE2b-256 |
d601b0e45284469ea751570dce36ea55ee41f26f975eb77498b955f7291f8a98
|