drisk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. drisk-0.1.0/.gitignore +16 -0
  2. drisk-0.1.0/LICENSE +21 -0
  3. drisk-0.1.0/PKG-INFO +171 -0
  4. drisk-0.1.0/README.md +144 -0
  5. drisk-0.1.0/pyproject.toml +91 -0
  6. drisk-0.1.0/src/drisk/__init__.py +89 -0
  7. drisk-0.1.0/src/drisk/_style.py +5 -0
  8. drisk-0.1.0/src/drisk/arithmetic.py +111 -0
  9. drisk-0.1.0/src/drisk/copulas/__init__.py +7 -0
  10. drisk-0.1.0/src/drisk/copulas/base.py +95 -0
  11. drisk-0.1.0/src/drisk/copulas/gaussian.py +38 -0
  12. drisk-0.1.0/src/drisk/copulas/registry.py +26 -0
  13. drisk-0.1.0/src/drisk/copulas/student_t.py +51 -0
  14. drisk-0.1.0/src/drisk/correlations/__init__.py +5 -0
  15. drisk-0.1.0/src/drisk/correlations/matrix.py +151 -0
  16. drisk-0.1.0/src/drisk/decision/__init__.py +23 -0
  17. drisk-0.1.0/src/drisk/decision/dtree/__init__.py +17 -0
  18. drisk-0.1.0/src/drisk/decision/dtree/_coercion.py +48 -0
  19. drisk-0.1.0/src/drisk/decision/dtree/_plotting.py +259 -0
  20. drisk-0.1.0/src/drisk/decision/dtree/_sampling.py +66 -0
  21. drisk-0.1.0/src/drisk/decision/dtree/_types.py +7 -0
  22. drisk-0.1.0/src/drisk/decision/dtree/branches.py +6 -0
  23. drisk-0.1.0/src/drisk/decision/dtree/chance_branch.py +32 -0
  24. drisk-0.1.0/src/drisk/decision/dtree/decision_branch.py +31 -0
  25. drisk-0.1.0/src/drisk/decision/dtree/nodes/__init__.py +29 -0
  26. drisk-0.1.0/src/drisk/decision/dtree/nodes/base.py +50 -0
  27. drisk-0.1.0/src/drisk/decision/dtree/nodes/chance.py +104 -0
  28. drisk-0.1.0/src/drisk/decision/dtree/nodes/decision.py +105 -0
  29. drisk-0.1.0/src/drisk/decision/dtree/nodes/factory.py +27 -0
  30. drisk-0.1.0/src/drisk/decision/dtree/nodes/outcome.py +65 -0
  31. drisk-0.1.0/src/drisk/decision/dtree/tree.py +190 -0
  32. drisk-0.1.0/src/drisk/distributions/__init__.py +63 -0
  33. drisk-0.1.0/src/drisk/distributions/base.py +127 -0
  34. drisk-0.1.0/src/drisk/distributions/mixture.py +213 -0
  35. drisk-0.1.0/src/drisk/distributions/registry.py +57 -0
  36. drisk-0.1.0/src/drisk/distributions/types.py +18 -0
  37. drisk-0.1.0/src/drisk/distributions/univariate/__init__.py +53 -0
  38. drisk-0.1.0/src/drisk/distributions/univariate/base.py +52 -0
  39. drisk-0.1.0/src/drisk/distributions/univariate/continuous/__init__.py +32 -0
  40. drisk-0.1.0/src/drisk/distributions/univariate/continuous/base.py +111 -0
  41. drisk-0.1.0/src/drisk/distributions/univariate/continuous/beta.py +148 -0
  42. drisk-0.1.0/src/drisk/distributions/univariate/continuous/exponential.py +103 -0
  43. drisk-0.1.0/src/drisk/distributions/univariate/continuous/gamma.py +126 -0
  44. drisk-0.1.0/src/drisk/distributions/univariate/continuous/logitnormal.py +164 -0
  45. drisk-0.1.0/src/drisk/distributions/univariate/continuous/lognormal.py +137 -0
  46. drisk-0.1.0/src/drisk/distributions/univariate/continuous/normal.py +112 -0
  47. drisk-0.1.0/src/drisk/distributions/univariate/continuous/stretched_beta.py +216 -0
  48. drisk-0.1.0/src/drisk/distributions/univariate/discrete/__init__.py +19 -0
  49. drisk-0.1.0/src/drisk/distributions/univariate/discrete/base.py +108 -0
  50. drisk-0.1.0/src/drisk/distributions/univariate/discrete/bernoulli.py +98 -0
  51. drisk-0.1.0/src/drisk/distributions/univariate/discrete/binomial.py +131 -0
  52. drisk-0.1.0/src/drisk/distributions/univariate/discrete/geometric.py +116 -0
  53. drisk-0.1.0/src/drisk/distributions/univariate/discrete/negative_binomial.py +145 -0
  54. drisk-0.1.0/src/drisk/distributions/univariate/discrete/poisson.py +103 -0
  55. drisk-0.1.0/src/drisk/models/__init__.py +6 -0
  56. drisk-0.1.0/src/drisk/models/base.py +551 -0
  57. drisk-0.1.0/src/drisk/models/functions.py +10 -0
  58. drisk-0.1.0/src/drisk/models/py.typed +0 -0
  59. drisk-0.1.0/src/drisk/py.typed +0 -0
  60. drisk-0.1.0/src/drisk/random.py +34 -0
  61. drisk-0.1.0/src/drisk/sensitivity/__init__.py +5 -0
  62. drisk-0.1.0/src/drisk/sensitivity/_evaluate.py +52 -0
  63. drisk-0.1.0/src/drisk/sensitivity/_inputs.py +47 -0
  64. drisk-0.1.0/src/drisk/sensitivity/one_at_a_time.py +367 -0
  65. drisk-0.1.0/src/drisk/summary.py +101 -0
  66. drisk-0.1.0/tests/test_beta_distributions.py +67 -0
  67. drisk-0.1.0/tests/test_continuous_distributions.py +147 -0
  68. drisk-0.1.0/tests/test_copulas.py +76 -0
  69. drisk-0.1.0/tests/test_correlations/test_matrix.py +72 -0
  70. drisk-0.1.0/tests/test_decision_trees.py +231 -0
  71. drisk-0.1.0/tests/test_discrete_distributions.py +303 -0
  72. drisk-0.1.0/tests/test_distribution_base.py +72 -0
  73. drisk-0.1.0/tests/test_imports.py +23 -0
  74. drisk-0.1.0/tests/test_mc_models.py +352 -0
  75. drisk-0.1.0/tests/test_mixture_distribution.py +92 -0
  76. drisk-0.1.0/tests/test_sensitivity.py +145 -0
  77. drisk-0.1.0/tests/test_serialization_roundtrip.py +189 -0
  78. drisk-0.1.0/tests/test_uv_continuous_domains.py +16 -0
drisk-0.1.0/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Quarto-generated files
10
+ docs/_site/
11
+ docs/.quarto/
12
+ docs/objects.json
13
+ docs/reference/
14
+
15
+ # Virtual environments
16
+ .venv
drisk-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nicholas Dorsch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
drisk-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.4
2
+ Name: drisk
3
+ Version: 0.1.0
4
+ Summary: Composable tools for quick Monte Carlo modelling and distribution elicitation.
5
+ Project-URL: Documentation, https://nick-dorsch.github.io/drisk/
6
+ Project-URL: Repository, https://github.com/nick-dorsch/drisk
7
+ Project-URL: Issues, https://github.com/nick-dorsch/drisk/issues
8
+ Author: Nicholas Dorsch
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: distributions,elicitation,monte-carlo,probability,simulation,uncertainty
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
19
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
20
+ Requires-Python: >=3.12
21
+ Requires-Dist: matplotlib>=3.11.0
22
+ Requires-Dist: numpy>=2.2.4
23
+ Requires-Dist: pandas>=3.0.3
24
+ Requires-Dist: pydantic>=2.13.4
25
+ Requires-Dist: scipy>=1.17.1
26
+ Description-Content-Type: text/markdown
27
+
28
+ # drisk
29
+
30
+ Composable tools for quick Monte Carlo modelling, with an emphasis on distribution
31
+ elicitation and model composition.
32
+
33
+ `drisk` provides a compact, notebook-friendly API for probability distributions,
34
+ elicitation workflows, correlated sampling, decision trees, sensitivity analysis, and
35
+ composable Monte Carlo models.
36
+
37
+ > `drisk` is currently in alpha. APIs may change before a stable release.
38
+
39
+ ## Links
40
+
41
+ - Documentation: <https://nick-dorsch.github.io/drisk/>
42
+ - Repository: <https://github.com/nick-dorsch/drisk>
43
+ - Issues: <https://github.com/nick-dorsch/drisk/issues>
44
+
45
+ ## Installation
46
+
47
+ Install from PyPI:
48
+
49
+ ```bash
50
+ pip install drisk
51
+ ```
52
+
53
+ Or with `uv`:
54
+
55
+ ```bash
56
+ uv add drisk
57
+ ```
58
+
59
+ `drisk` requires Python 3.12 or newer.
60
+
61
+ ## Quick start
62
+
63
+ ```python
64
+ import drisk as dr
65
+
66
+ # Elicit a distribution from intuitive inputs.
67
+ dist = dr.LogitNormal.elicit(low=0.1, high=0.25)
68
+
69
+ # Draw Monte Carlo samples.
70
+ samples = dist.sample(1_000)
71
+ ```
72
+
73
+ ## Features
74
+
75
+ - Continuous distributions such as `Normal`, `LogNormal`, `LogitNormal`, `Beta`, `PERT`, `Gamma`, and `Exponential`
76
+ - Discrete distributions such as `Bernoulli`, `Binomial`, `Poisson`, `Geometric`, and `NegativeBinomial`
77
+ - Distribution elicitation, fitting, sampling, plotting, and serialization-friendly parameters
78
+ - Mixture distributions with `UvMixture`
79
+ - Correlation matrix helpers and Gaussian / Student-t copulas
80
+ - Composable Monte Carlo models via `MCModel`, `MCOperation`, and `where`
81
+ - Decision tree modelling with chance, decision, and outcome nodes
82
+ - One-at-a-time sensitivity analysis helpers
83
+
84
+ ## Documentation
85
+
86
+ The documentation site includes examples and API reference pages:
87
+
88
+ <https://nick-dorsch.github.io/drisk/>
89
+
90
+ ## Developer setup
91
+
92
+ This repository uses:
93
+
94
+ - [mise](https://mise.jdx.dev/) to install local development tools and run common project tasks
95
+ - [uv](https://docs.astral.sh/uv/) for Python dependency management and command execution
96
+
97
+ ### 1. Install tools with mise
98
+
99
+ Install `mise` if you do not already have it, then install the tools pinned in
100
+ `.mise.toml`:
101
+
102
+ ```bash
103
+ mise install
104
+ ```
105
+
106
+ This installs the project Python version, `uv`, `ruff`, and other helper tools for the
107
+ repository.
108
+
109
+ ### 2. Install Python dependencies with uv
110
+
111
+ Sync the project environment from `pyproject.toml` and `uv.lock`:
112
+
113
+ ```bash
114
+ uv sync --all-groups
115
+ ```
116
+
117
+ Use `uv run ...` for commands that should execute inside the managed environment:
118
+
119
+ ```bash
120
+ uv run pytest
121
+ uv run ruff check .
122
+ uv run python -c "import drisk as dr; print(dr.Normal.elicit(0, 1))"
123
+ ```
124
+
125
+ When adding dependencies, use `uv add` so `pyproject.toml` and `uv.lock` stay in sync:
126
+
127
+ ```bash
128
+ uv add numpy
129
+ uv add --dev pytest
130
+ uv add --group docs jupyter
131
+ ```
132
+
133
+ ### 3. Run project tasks with mise
134
+
135
+ List available tasks:
136
+
137
+ ```bash
138
+ mise tasks
139
+ ```
140
+
141
+ Common tasks:
142
+
143
+ ```bash
144
+ mise run test # run the test suite
145
+ mise run lint # run ruff checks
146
+ mise run format # format the codebase
147
+ mise run check # run lint and tests
148
+ mise run docs # preview the Quarto documentation site
149
+ ```
150
+
151
+ ## Project layout
152
+
153
+ ```text
154
+ src/drisk/
155
+ copulas/ # copula interfaces and implementations
156
+ correlations/ # correlation matrix helpers
157
+ decision/ # decision tree nodes, branches, and trees
158
+ distributions/ # distribution interfaces and implementations
159
+ models/ # composable Monte Carlo model helpers
160
+ sensitivity/ # sensitivity analysis utilities
161
+ arithmetic.py # arithmetic/composition helpers
162
+ random.py # seed/RNG helpers
163
+ summary.py # summary helpers
164
+
165
+ tests/ # pytest suite
166
+ docs/ # Quarto documentation site
167
+ ```
168
+
169
+ ## License
170
+
171
+ `drisk` is distributed under the MIT License. See [LICENSE](LICENSE) for details.
drisk-0.1.0/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # drisk
2
+
3
+ Composable tools for quick Monte Carlo modelling, with an emphasis on distribution
4
+ elicitation and model composition.
5
+
6
+ `drisk` provides a compact, notebook-friendly API for probability distributions,
7
+ elicitation workflows, correlated sampling, decision trees, sensitivity analysis, and
8
+ composable Monte Carlo models.
9
+
10
+ > `drisk` is currently in alpha. APIs may change before a stable release.
11
+
12
+ ## Links
13
+
14
+ - Documentation: <https://nick-dorsch.github.io/drisk/>
15
+ - Repository: <https://github.com/nick-dorsch/drisk>
16
+ - Issues: <https://github.com/nick-dorsch/drisk/issues>
17
+
18
+ ## Installation
19
+
20
+ Install from PyPI:
21
+
22
+ ```bash
23
+ pip install drisk
24
+ ```
25
+
26
+ Or with `uv`:
27
+
28
+ ```bash
29
+ uv add drisk
30
+ ```
31
+
32
+ `drisk` requires Python 3.12 or newer.
33
+
34
+ ## Quick start
35
+
36
+ ```python
37
+ import drisk as dr
38
+
39
+ # Elicit a distribution from intuitive inputs.
40
+ dist = dr.LogitNormal.elicit(low=0.1, high=0.25)
41
+
42
+ # Draw Monte Carlo samples.
43
+ samples = dist.sample(1_000)
44
+ ```
45
+
46
+ ## Features
47
+
48
+ - Continuous distributions such as `Normal`, `LogNormal`, `LogitNormal`, `Beta`, `PERT`, `Gamma`, and `Exponential`
49
+ - Discrete distributions such as `Bernoulli`, `Binomial`, `Poisson`, `Geometric`, and `NegativeBinomial`
50
+ - Distribution elicitation, fitting, sampling, plotting, and serialization-friendly parameters
51
+ - Mixture distributions with `UvMixture`
52
+ - Correlation matrix helpers and Gaussian / Student-t copulas
53
+ - Composable Monte Carlo models via `MCModel`, `MCOperation`, and `where`
54
+ - Decision tree modelling with chance, decision, and outcome nodes
55
+ - One-at-a-time sensitivity analysis helpers
56
+
57
+ ## Documentation
58
+
59
+ The documentation site includes examples and API reference pages:
60
+
61
+ <https://nick-dorsch.github.io/drisk/>
62
+
63
+ ## Developer setup
64
+
65
+ This repository uses:
66
+
67
+ - [mise](https://mise.jdx.dev/) to install local development tools and run common project tasks
68
+ - [uv](https://docs.astral.sh/uv/) for Python dependency management and command execution
69
+
70
+ ### 1. Install tools with mise
71
+
72
+ Install `mise` if you do not already have it, then install the tools pinned in
73
+ `.mise.toml`:
74
+
75
+ ```bash
76
+ mise install
77
+ ```
78
+
79
+ This installs the project Python version, `uv`, `ruff`, and other helper tools for the
80
+ repository.
81
+
82
+ ### 2. Install Python dependencies with uv
83
+
84
+ Sync the project environment from `pyproject.toml` and `uv.lock`:
85
+
86
+ ```bash
87
+ uv sync --all-groups
88
+ ```
89
+
90
+ Use `uv run ...` for commands that should execute inside the managed environment:
91
+
92
+ ```bash
93
+ uv run pytest
94
+ uv run ruff check .
95
+ uv run python -c "import drisk as dr; print(dr.Normal.elicit(0, 1))"
96
+ ```
97
+
98
+ When adding dependencies, use `uv add` so `pyproject.toml` and `uv.lock` stay in sync:
99
+
100
+ ```bash
101
+ uv add numpy
102
+ uv add --dev pytest
103
+ uv add --group docs jupyter
104
+ ```
105
+
106
+ ### 3. Run project tasks with mise
107
+
108
+ List available tasks:
109
+
110
+ ```bash
111
+ mise tasks
112
+ ```
113
+
114
+ Common tasks:
115
+
116
+ ```bash
117
+ mise run test # run the test suite
118
+ mise run lint # run ruff checks
119
+ mise run format # format the codebase
120
+ mise run check # run lint and tests
121
+ mise run docs # preview the Quarto documentation site
122
+ ```
123
+
124
+ ## Project layout
125
+
126
+ ```text
127
+ src/drisk/
128
+ copulas/ # copula interfaces and implementations
129
+ correlations/ # correlation matrix helpers
130
+ decision/ # decision tree nodes, branches, and trees
131
+ distributions/ # distribution interfaces and implementations
132
+ models/ # composable Monte Carlo model helpers
133
+ sensitivity/ # sensitivity analysis utilities
134
+ arithmetic.py # arithmetic/composition helpers
135
+ random.py # seed/RNG helpers
136
+ summary.py # summary helpers
137
+
138
+ tests/ # pytest suite
139
+ docs/ # Quarto documentation site
140
+ ```
141
+
142
+ ## License
143
+
144
+ `drisk` is distributed under the MIT License. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,91 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "drisk"
7
+ version = "0.1.0"
8
+ description = "Composable tools for quick Monte Carlo modelling and distribution elicitation."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ authors = [
12
+ { name = "Nicholas Dorsch" },
13
+ ]
14
+ license = { text = "MIT" }
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Intended Audience :: Science/Research",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Scientific/Engineering :: Mathematics",
23
+ "Topic :: Scientific/Engineering :: Information Analysis",
24
+ ]
25
+ keywords = [
26
+ "monte-carlo",
27
+ "simulation",
28
+ "probability",
29
+ "distributions",
30
+ "elicitation",
31
+ "uncertainty",
32
+ ]
33
+
34
+ dependencies = [
35
+ "matplotlib>=3.11.0",
36
+ "numpy>=2.2.4",
37
+ "pandas>=3.0.3",
38
+ "pydantic>=2.13.4",
39
+ "scipy>=1.17.1",
40
+ ]
41
+
42
+ [project.urls]
43
+ Documentation = "https://nick-dorsch.github.io/drisk/"
44
+ Repository = "https://github.com/nick-dorsch/drisk"
45
+ Issues = "https://github.com/nick-dorsch/drisk/issues"
46
+
47
+ [dependency-groups]
48
+ dev = [
49
+ "mypy>=1.19.1",
50
+ "pytest>=9.0.2",
51
+ "pytest-cov>=7.0.0",
52
+ "ruff>=0.14.14",
53
+ ]
54
+ docs = [
55
+ "ipykernel>=7.3.0",
56
+ "jupyter>=1.1.1",
57
+ "nbclient>=0.11.0",
58
+ "pyyaml>=6.0.3",
59
+ "quartodoc>=0.9.1",
60
+ ]
61
+
62
+ [tool.hatch.build.targets.wheel]
63
+ packages = ["src/drisk"]
64
+
65
+ [tool.hatch.build.targets.sdist]
66
+ include = [
67
+ "/src",
68
+ "/tests",
69
+ "/README.md",
70
+ "/LICENSE",
71
+ "/pyproject.toml",
72
+ ]
73
+
74
+ [tool.ruff]
75
+ line-length = 88
76
+ target-version = "py312"
77
+
78
+ [tool.ruff.lint]
79
+ select = ["E", "W", "F", "I", "B", "C4", "UP", "PT", "SIM"]
80
+ ignore = [
81
+ "B008",
82
+ "E501",
83
+ ]
84
+
85
+ [tool.ruff.format]
86
+ quote-style = "double"
87
+ indent-style = "space"
88
+
89
+ [tool.pytest.ini_options]
90
+ testpaths = ["tests"]
91
+ pythonpath = ["src"]
@@ -0,0 +1,89 @@
1
+ """Convenient tools for quick Monte Carlo modelling."""
2
+
3
+ from . import _style as _style
4
+ from .copulas import Copula, GaussianCopula, StudentTCopula
5
+ from .correlations import CorrelationMatrix
6
+ from .decision import (
7
+ ChanceBranch,
8
+ ChanceNode,
9
+ DecisionBranch,
10
+ DecisionNode,
11
+ DTree,
12
+ DTreeNode,
13
+ OutcomeNode,
14
+ )
15
+ from .distributions import (
16
+ PERT,
17
+ ArrayLike,
18
+ Bernoulli,
19
+ Beta,
20
+ Binomial,
21
+ DataFrameLike,
22
+ Distribution,
23
+ Exponential,
24
+ Gamma,
25
+ Geometric,
26
+ LogitNormal,
27
+ LogNormal,
28
+ NegativeBinomial,
29
+ Normal,
30
+ Poisson,
31
+ StretchedBeta,
32
+ UvBoundedContinuous,
33
+ UvContinuous,
34
+ UvCountDiscrete,
35
+ UvDiscrete,
36
+ UvDistribution,
37
+ UvFiniteDiscrete,
38
+ UvMixture,
39
+ UvPositiveContinuous,
40
+ UvRealContinuous,
41
+ UvUnitBoundedContinuous,
42
+ )
43
+ from .models import MCModel, MCOperation, where
44
+ from .sensitivity import OneAtATimeSensitivity, one_at_a_time
45
+
46
+ __all__ = [
47
+ "ArrayLike",
48
+ "Bernoulli",
49
+ "Beta",
50
+ "Binomial",
51
+ "ChanceBranch",
52
+ "ChanceNode",
53
+ "Copula",
54
+ "CorrelationMatrix",
55
+ "DataFrameLike",
56
+ "DecisionBranch",
57
+ "DecisionNode",
58
+ "Distribution",
59
+ "DTree",
60
+ "DTreeNode",
61
+ "Exponential",
62
+ "GaussianCopula",
63
+ "Gamma",
64
+ "Geometric",
65
+ "LogitNormal",
66
+ "MCModel",
67
+ "MCOperation",
68
+ "LogNormal",
69
+ "UvMixture",
70
+ "NegativeBinomial",
71
+ "Normal",
72
+ "OneAtATimeSensitivity",
73
+ "OutcomeNode",
74
+ "one_at_a_time",
75
+ "PERT",
76
+ "Poisson",
77
+ "StudentTCopula",
78
+ "StretchedBeta",
79
+ "UvBoundedContinuous",
80
+ "UvContinuous",
81
+ "UvCountDiscrete",
82
+ "UvDiscrete",
83
+ "UvDistribution",
84
+ "UvFiniteDiscrete",
85
+ "UvPositiveContinuous",
86
+ "UvRealContinuous",
87
+ "UvUnitBoundedContinuous",
88
+ "where",
89
+ ]
@@ -0,0 +1,5 @@
1
+ """Package-wide Matplotlib defaults."""
2
+
3
+ import matplotlib as mpl
4
+
5
+ mpl.rcParams.update({"axes.grid": True, "grid.alpha": 0.25})
@@ -0,0 +1,111 @@
1
+ """Arithmetic helpers for composable Monte Carlo expressions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+
8
+ class ArithmeticMixin:
9
+ """Mixin that turns arithmetic into lazy Monte Carlo model expressions."""
10
+
11
+ def __add__(self, other: Any) -> Any:
12
+ """Create a lazy model for ``self + other``."""
13
+ from drisk.models import MCModel, MCOperation
14
+
15
+ return MCModel.from_operation(MCOperation.ADD, self, other)
16
+
17
+ def __radd__(self, other: Any) -> Any:
18
+ """Create a lazy model for ``other + self``."""
19
+ from drisk.models import MCModel, MCOperation
20
+
21
+ return MCModel.from_operation(MCOperation.ADD, other, self)
22
+
23
+ def __sub__(self, other: Any) -> Any:
24
+ """Create a lazy model for ``self - other``."""
25
+ from drisk.models import MCModel, MCOperation
26
+
27
+ return MCModel.from_operation(MCOperation.SUBTRACT, self, other)
28
+
29
+ def __rsub__(self, other: Any) -> Any:
30
+ """Create a lazy model for ``other - self``."""
31
+ from drisk.models import MCModel, MCOperation
32
+
33
+ return MCModel.from_operation(MCOperation.SUBTRACT, other, self)
34
+
35
+ def __mul__(self, other: Any) -> Any:
36
+ """Create a lazy model for ``self * other``."""
37
+ from drisk.models import MCModel, MCOperation
38
+
39
+ return MCModel.from_operation(MCOperation.MULTIPLY, self, other)
40
+
41
+ def __rmul__(self, other: Any) -> Any:
42
+ """Create a lazy model for ``other * self``."""
43
+ from drisk.models import MCModel, MCOperation
44
+
45
+ return MCModel.from_operation(MCOperation.MULTIPLY, other, self)
46
+
47
+ def __truediv__(self, other: Any) -> Any:
48
+ """Create a lazy model for ``self / other``."""
49
+ from drisk.models import MCModel, MCOperation
50
+
51
+ return MCModel.from_operation(MCOperation.DIVIDE, self, other)
52
+
53
+ def __rtruediv__(self, other: Any) -> Any:
54
+ """Create a lazy model for ``other / self``."""
55
+ from drisk.models import MCModel, MCOperation
56
+
57
+ return MCModel.from_operation(MCOperation.DIVIDE, other, self)
58
+
59
+ def __pow__(self, other: Any) -> Any:
60
+ """Create a lazy model for ``self ** other``."""
61
+ from drisk.models import MCModel, MCOperation
62
+
63
+ return MCModel.from_operation(MCOperation.POWER, self, other)
64
+
65
+ def __rpow__(self, other: Any) -> Any:
66
+ """Create a lazy model for ``other ** self``."""
67
+ from drisk.models import MCModel, MCOperation
68
+
69
+ return MCModel.from_operation(MCOperation.POWER, other, self)
70
+
71
+ def __lt__(self, other: Any) -> Any:
72
+ """Create a lazy model for ``self < other``."""
73
+ from drisk.models import MCModel, MCOperation
74
+
75
+ return MCModel.from_operation(MCOperation.LESS, self, other)
76
+
77
+ def __le__(self, other: Any) -> Any:
78
+ """Create a lazy model for ``self <= other``."""
79
+ from drisk.models import MCModel, MCOperation
80
+
81
+ return MCModel.from_operation(MCOperation.LESS_EQUAL, self, other)
82
+
83
+ def __gt__(self, other: Any) -> Any:
84
+ """Create a lazy model for ``self > other``."""
85
+ from drisk.models import MCModel, MCOperation
86
+
87
+ return MCModel.from_operation(MCOperation.GREATER, self, other)
88
+
89
+ def __ge__(self, other: Any) -> Any:
90
+ """Create a lazy model for ``self >= other``."""
91
+ from drisk.models import MCModel, MCOperation
92
+
93
+ return MCModel.from_operation(MCOperation.GREATER_EQUAL, self, other)
94
+
95
+ def __neg__(self) -> Any:
96
+ """Create a lazy model for ``-self``."""
97
+ from drisk.models import MCModel, MCOperation
98
+
99
+ return MCModel.from_operation(MCOperation.NEGATIVE, self)
100
+
101
+ def __pos__(self) -> Any:
102
+ """Create a lazy model for ``+self``."""
103
+ from drisk.models import MCModel, MCOperation
104
+
105
+ return MCModel.from_operation(MCOperation.POSITIVE, self)
106
+
107
+ def __abs__(self) -> Any:
108
+ """Create a lazy model for ``abs(self)``."""
109
+ from drisk.models import MCModel, MCOperation
110
+
111
+ return MCModel.from_operation(MCOperation.ABS, self)
@@ -0,0 +1,7 @@
1
+ """Copula models for jointly sampling marginal distributions."""
2
+
3
+ from .base import Copula
4
+ from .gaussian import GaussianCopula
5
+ from .student_t import StudentTCopula
6
+
7
+ __all__ = ["Copula", "GaussianCopula", "StudentTCopula"]