simulatingrisk 1.0.0.post1__tar.gz → 1.1.0.dev0__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.
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/PKG-INFO +40 -15
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/README.md +35 -9
- simulatingrisk-1.1.0.dev0/docs/notebooks/hawkdovemulti-adjust/hdm_c7_hawkodds.html +10623 -0
- simulatingrisk-1.1.0.dev0/docs/notebooks/hawkdovemulti-adjust/hdm_c7_riskdistribution.html +8432 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/docs/notebooks/hawkdovemulti-noadjust/index.html +625 -547
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/README.md +2 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/hawkdovemulti_adjust/hawkdovevar_population_risk_category.ipynb +42 -42
- simulatingrisk-1.1.0.dev0/notebooks/hawkdovemulti_adjust/hdm_analysis.ipynb +925 -0
- simulatingrisk-1.1.0.dev0/notebooks/hawkdovemulti_adjust/hdm_c7_hawkodds.ipynb +3214 -0
- simulatingrisk-1.1.0.dev0/notebooks/hawkdovemulti_adjust/hdm_c7_riskdistribution.ipynb +931 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/hawkdovemulti_noadjust/analyze_batchrun_data.ipynb +628 -559
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/pyproject.toml +4 -3
- simulatingrisk-1.1.0.dev0/simulatingrisk/__init__.py +1 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdove/app.py +8 -6
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdove/server.py +19 -20
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdovemulti/analysis_utils.py +6 -9
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdovemulti/app.py +15 -16
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk.egg-info/PKG-INFO +40 -15
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk.egg-info/requires.txt +4 -5
- simulatingrisk-1.0.0.post1/docs/notebooks/hawkdovemulti-adjust/hdm_c7_hawkodds.html +0 -10639
- simulatingrisk-1.0.0.post1/docs/notebooks/hawkdovemulti-adjust/hdm_c7_riskdistribution.html +0 -8263
- simulatingrisk-1.0.0.post1/notebooks/hawkdovemulti_adjust/hdm_analysis.ipynb +0 -1429
- simulatingrisk-1.0.0.post1/notebooks/hawkdovemulti_adjust/hdm_c7_hawkodds.ipynb +0 -3230
- simulatingrisk-1.0.0.post1/notebooks/hawkdovemulti_adjust/hdm_c7_riskdistribution.ipynb +0 -764
- simulatingrisk-1.0.0.post1/simulatingrisk/__init__.py +0 -1
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/.github/workflows/unit_tests.yml +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/.gitignore +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/.pre-commit-config.yaml +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/LICENSE +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/docs/index.html +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/docs/notebooks/hawkdovemulti-adjust/hdm_analysis.html +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/docs/notebooks/hawkdovemulti-adjust/hdm_convergence_runlength.html +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/docs/notebooks/hawkdovemulti-adjust/hdm_riskadjust_runlength.html +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/docs/notebooks/hawkdovemulti-adjust/index.html +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/docs/notebooks/hawkdovemulti-adjust/parameter_analysis.html +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/docs/notebooks/index.html +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/docs/simulatingrisk-0.1.0.dev0-py3-none-any.whl +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/hawkdove_single_r/hawkdove_single_r_analysis.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/hawkdovemulti_adjust/hawkdovemulti_agentrisktotals.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/hawkdovemulti_adjust/hawkdovemulti_polars.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/hawkdovemulti_adjust/hawkdovemulti_runlength.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/hawkdovemulti_adjust/hdm_riskadjust_runlength.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/hawkdovemulti_noadjust/hawkdove_variable_r_analysis.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/new_convergence/hdm_convergence_runlength.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/riskybet/riskybet_batch_analysis.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/riskybet/riskybet_simulation.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/riskyfood/riskyfood_batch_analysis.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/notebooks/riskyfood/riskyfood_simulation.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/postBuild +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/setup.cfg +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/about_app.md +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/app.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/batch_run.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/charts/histogram.js +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/charts/histogram.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdove/README.md +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdove/model.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdove/run.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdovemulti/README.md +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdovemulti/batch_run.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdovemulti/model.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdovemulti/run_simulation.ipynb +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/hawkdovemulti/simrisk_batch.slurm +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/risky_bet/README.md +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/risky_bet/app.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/risky_bet/model.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/risky_bet/run.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/risky_bet/server.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/risky_food/README.md +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/risky_food/__init__.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/risky_food/app.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/risky_food/model.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/risky_food/run.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/risky_food/server.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/stag_hunt/README.md +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/stag_hunt/__init__.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/stag_hunt/model.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/stag_hunt/run.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk/utils.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk.egg-info/SOURCES.txt +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk.egg-info/dependency_links.txt +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk.egg-info/entry_points.txt +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/simulatingrisk.egg-info/top_level.txt +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/tests/test_batch_run.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/tests/test_hawkdove.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/tests/test_hawkdovemulti.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/tests/test_risky_bet.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/tests/test_risky_food.py +0 -0
- {simulatingrisk-1.0.0.post1 → simulatingrisk-1.1.0.dev0}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simulatingrisk
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.0.dev0
|
|
4
4
|
Summary: Agent-based modeling for simulations related to risk and rationality
|
|
5
5
|
License: Apache-2
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -9,27 +9,28 @@ Description-Content-Type: text/markdown
|
|
|
9
9
|
License-File: LICENSE
|
|
10
10
|
Requires-Dist: mesa==2.1.5
|
|
11
11
|
Requires-Dist: matplotlib
|
|
12
|
-
Requires-Dist: altair
|
|
12
|
+
Requires-Dist: altair>=6.1.0
|
|
13
13
|
Provides-Extra: dev
|
|
14
14
|
Requires-Dist: pre-commit; extra == "dev"
|
|
15
15
|
Requires-Dist: pytest; extra == "dev"
|
|
16
16
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
17
17
|
Provides-Extra: analysis
|
|
18
18
|
Requires-Dist: jupyterlab; extra == "analysis"
|
|
19
|
-
Requires-Dist: polars; extra == "analysis"
|
|
19
|
+
Requires-Dist: polars>1.41.2; extra == "analysis"
|
|
20
20
|
Requires-Dist: hvplot; extra == "analysis"
|
|
21
21
|
Requires-Dist: pyarrow; extra == "analysis"
|
|
22
|
-
Requires-Dist: altair; extra == "analysis"
|
|
23
22
|
Requires-Dist: scipy; extra == "analysis"
|
|
24
23
|
Requires-Dist: scikit-learn; extra == "analysis"
|
|
25
24
|
Requires-Dist: seaborn; extra == "analysis"
|
|
26
|
-
Requires-Dist: vegafusion[embed]>=
|
|
27
|
-
Requires-Dist: vl-convert-python; extra == "analysis"
|
|
25
|
+
Requires-Dist: vegafusion[embed]>=2.0.3; extra == "analysis"
|
|
26
|
+
Requires-Dist: vl-convert-python>=1.9.0; extra == "analysis"
|
|
28
27
|
Requires-Dist: great-tables; extra == "analysis"
|
|
29
28
|
Dynamic: license-file
|
|
30
29
|
|
|
31
30
|
# Simulating Risk
|
|
32
31
|
|
|
32
|
+
|
|
33
|
+
[](https://doi.org/10.5281/zenodo.18361156)
|
|
33
34
|
[](https://github.com/DHCodeReview/simulating-risk/pull/1) [](https://github.com/Princeton-CDH/simulating-risk/actions/workflows/unit_tests.yml)
|
|
34
35
|
|
|
35
36
|
The code in this repository is associated with the CDH project [Simulating risk, risking simulations](https://cdh.princeton.edu/projects/simulating-risk/).
|
|
@@ -38,17 +39,18 @@ Simulations are implemented with [Mesa](https://mesa.readthedocs.io/en/stable/),
|
|
|
38
39
|
|
|
39
40
|
----
|
|
40
41
|
|
|
41
|
-
## Simulations with agent interaction
|
|
42
|
+
## Simulations with risk attitudes and agent interaction
|
|
42
43
|
|
|
43
44
|
- [Hawk/Dove with risk attitudes](simulatingrisk/hawkdove)
|
|
44
45
|
- [Hawk/Dove with multiple risk attitudes and adjustment](simulatingrisk/hawkdovemulti)
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
> [!TIP]
|
|
48
|
+
Run an interactive version of the simulation online: [Hawk/Dove with multiple risk attitudes](https://py.cafe/rlskoeser/simulatingrisk-hawk-dove-multirisk)
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
> [!NOTE]
|
|
51
|
+
Altenately, run the simulation in a Jupyter notebook: [](https://mybinder.org/v2/gh/Princeton-CDH/simulating-risk.git/HEAD?urlpath=%2Fdoc%2Ftree%2Fsimulatingrisk%2Fhawkdovemulti%2Frun_simulation.ipynb)
|
|
50
52
|
|
|
51
|
-
The
|
|
53
|
+
The code for **Hawk/Dove with risk attitudes** and **Hawk/Dove with multiple risk attitudes** in this codebase was [reviewed](https://github.com/DHCodeReview/simulating-risk/pull/1) in June 2024 by [Scott Foster](https://github.com/sgfost) and [Malte Vogl](https://github.com/maltevogl) (Senior Research Fellow, Max Planck Institute of Geoanthropology) via [DHTech Community Code Review](https://dhcodereview.github.io/); review was facilitated by [Cole Crawford](https://github.com/ColeDCrawford) (Senior Software Engineer, Harvard Arts and Humanities Research Computing).
|
|
52
54
|
|
|
53
55
|
## Simulations with risky choices (environment)
|
|
54
56
|
|
|
@@ -62,19 +64,34 @@ Across simulations, we define agents with risk attitudes tracked via a numeric `
|
|
|
62
64
|
When the risky bet might be better or worse than the safe bet by the same amount (for example, the risky bet yields 3 or 1 and the safe bet yields 2), an agent who maximizes expected utility will prefer the risky bet when p > 0.5 and will prefer the safe bet when 'p < 0.5'; and they will be indifferent between the risky bet and the safe bet. Thus, r = 0.5 corresponds to expected utility maximization except in the case in which the probability is exactly 0.5 (or, we might say, a point epsilon units to the left of 0.5, where epsilon is smaller than the fineness of our random number generator, corresponds to expected utility maximization). These complications make no difference in practice, so we can simply say that r = 0.5 corresponds to expected utility maximization.
|
|
63
65
|
|
|
64
66
|
|
|
67
|
+
```mermaid
|
|
68
|
+
---
|
|
69
|
+
title: risk attitude / risk level (for probabilistic choices)
|
|
70
|
+
---
|
|
71
|
+
flowchart LR
|
|
72
|
+
r0["<b>0.0</b>
|
|
73
|
+
always takes risky choice
|
|
74
|
+
(any risk is acceptable)"]
|
|
75
|
+
reu["<b>0.5</b>
|
|
76
|
+
risk neutral
|
|
77
|
+
(expected utility maximizer)"]
|
|
78
|
+
r1["<b>1.0</b>
|
|
79
|
+
always takes safe choice
|
|
80
|
+
(no risk is acceptable)"]
|
|
81
|
+
r0 ---|risk seeking|reu---|risk averse|r1
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
65
85
|
## Development instructions
|
|
66
86
|
|
|
67
87
|
Initial setup and installation:
|
|
68
88
|
|
|
69
89
|
- *Recommmended*: create and activate a Python 3.12 virtualenv:
|
|
70
|
-
|
|
71
90
|
```sh
|
|
72
91
|
python3 -m venv simrisk
|
|
73
92
|
source simrisk/bin/activate
|
|
74
93
|
```
|
|
75
|
-
|
|
76
94
|
- Install the package, dependencies, and development dependencies:
|
|
77
|
-
|
|
78
95
|
```sh
|
|
79
96
|
pip install -e .
|
|
80
97
|
pip install -e ".[dev]"
|
|
@@ -94,7 +111,7 @@ An interactive version of the [Solara app with tabs for all simulations](https:/
|
|
|
94
111
|
is available online.
|
|
95
112
|
|
|
96
113
|
|
|
97
|
-
### Running the simulations
|
|
114
|
+
### Running the simulations (non-solara versions)
|
|
98
115
|
|
|
99
116
|
- Simulations can be run interactively with mesa runserver by specifying
|
|
100
117
|
the path to the model, e.g. `mesa runserver simulatingrisk/risky_bet/`
|
|
@@ -111,3 +128,11 @@ Install pre-commit hooks (currently [black](https://github.com/psf/black) and [r
|
|
|
111
128
|
```sh
|
|
112
129
|
pre-commit install
|
|
113
130
|
```
|
|
131
|
+
|
|
132
|
+
### To run on py.cafe
|
|
133
|
+
|
|
134
|
+
Build the application as a wheel, excluding dependencies:
|
|
135
|
+
|
|
136
|
+
```sh
|
|
137
|
+
pip wheel . --no-deps
|
|
138
|
+
```
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Simulating Risk
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
[](https://doi.org/10.5281/zenodo.18361156)
|
|
3
5
|
[](https://github.com/DHCodeReview/simulating-risk/pull/1) [](https://github.com/Princeton-CDH/simulating-risk/actions/workflows/unit_tests.yml)
|
|
4
6
|
|
|
5
7
|
The code in this repository is associated with the CDH project [Simulating risk, risking simulations](https://cdh.princeton.edu/projects/simulating-risk/).
|
|
@@ -8,17 +10,18 @@ Simulations are implemented with [Mesa](https://mesa.readthedocs.io/en/stable/),
|
|
|
8
10
|
|
|
9
11
|
----
|
|
10
12
|
|
|
11
|
-
## Simulations with agent interaction
|
|
13
|
+
## Simulations with risk attitudes and agent interaction
|
|
12
14
|
|
|
13
15
|
- [Hawk/Dove with risk attitudes](simulatingrisk/hawkdove)
|
|
14
16
|
- [Hawk/Dove with multiple risk attitudes and adjustment](simulatingrisk/hawkdovemulti)
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
> [!TIP]
|
|
19
|
+
Run an interactive version of the simulation online: [Hawk/Dove with multiple risk attitudes](https://py.cafe/rlskoeser/simulatingrisk-hawk-dove-multirisk)
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
> [!NOTE]
|
|
22
|
+
Altenately, run the simulation in a Jupyter notebook: [](https://mybinder.org/v2/gh/Princeton-CDH/simulating-risk.git/HEAD?urlpath=%2Fdoc%2Ftree%2Fsimulatingrisk%2Fhawkdovemulti%2Frun_simulation.ipynb)
|
|
20
23
|
|
|
21
|
-
The
|
|
24
|
+
The code for **Hawk/Dove with risk attitudes** and **Hawk/Dove with multiple risk attitudes** in this codebase was [reviewed](https://github.com/DHCodeReview/simulating-risk/pull/1) in June 2024 by [Scott Foster](https://github.com/sgfost) and [Malte Vogl](https://github.com/maltevogl) (Senior Research Fellow, Max Planck Institute of Geoanthropology) via [DHTech Community Code Review](https://dhcodereview.github.io/); review was facilitated by [Cole Crawford](https://github.com/ColeDCrawford) (Senior Software Engineer, Harvard Arts and Humanities Research Computing).
|
|
22
25
|
|
|
23
26
|
## Simulations with risky choices (environment)
|
|
24
27
|
|
|
@@ -32,19 +35,34 @@ Across simulations, we define agents with risk attitudes tracked via a numeric `
|
|
|
32
35
|
When the risky bet might be better or worse than the safe bet by the same amount (for example, the risky bet yields 3 or 1 and the safe bet yields 2), an agent who maximizes expected utility will prefer the risky bet when p > 0.5 and will prefer the safe bet when 'p < 0.5'; and they will be indifferent between the risky bet and the safe bet. Thus, r = 0.5 corresponds to expected utility maximization except in the case in which the probability is exactly 0.5 (or, we might say, a point epsilon units to the left of 0.5, where epsilon is smaller than the fineness of our random number generator, corresponds to expected utility maximization). These complications make no difference in practice, so we can simply say that r = 0.5 corresponds to expected utility maximization.
|
|
33
36
|
|
|
34
37
|
|
|
38
|
+
```mermaid
|
|
39
|
+
---
|
|
40
|
+
title: risk attitude / risk level (for probabilistic choices)
|
|
41
|
+
---
|
|
42
|
+
flowchart LR
|
|
43
|
+
r0["<b>0.0</b>
|
|
44
|
+
always takes risky choice
|
|
45
|
+
(any risk is acceptable)"]
|
|
46
|
+
reu["<b>0.5</b>
|
|
47
|
+
risk neutral
|
|
48
|
+
(expected utility maximizer)"]
|
|
49
|
+
r1["<b>1.0</b>
|
|
50
|
+
always takes safe choice
|
|
51
|
+
(no risk is acceptable)"]
|
|
52
|
+
r0 ---|risk seeking|reu---|risk averse|r1
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
|
|
35
56
|
## Development instructions
|
|
36
57
|
|
|
37
58
|
Initial setup and installation:
|
|
38
59
|
|
|
39
60
|
- *Recommmended*: create and activate a Python 3.12 virtualenv:
|
|
40
|
-
|
|
41
61
|
```sh
|
|
42
62
|
python3 -m venv simrisk
|
|
43
63
|
source simrisk/bin/activate
|
|
44
64
|
```
|
|
45
|
-
|
|
46
65
|
- Install the package, dependencies, and development dependencies:
|
|
47
|
-
|
|
48
66
|
```sh
|
|
49
67
|
pip install -e .
|
|
50
68
|
pip install -e ".[dev]"
|
|
@@ -64,7 +82,7 @@ An interactive version of the [Solara app with tabs for all simulations](https:/
|
|
|
64
82
|
is available online.
|
|
65
83
|
|
|
66
84
|
|
|
67
|
-
### Running the simulations
|
|
85
|
+
### Running the simulations (non-solara versions)
|
|
68
86
|
|
|
69
87
|
- Simulations can be run interactively with mesa runserver by specifying
|
|
70
88
|
the path to the model, e.g. `mesa runserver simulatingrisk/risky_bet/`
|
|
@@ -81,3 +99,11 @@ Install pre-commit hooks (currently [black](https://github.com/psf/black) and [r
|
|
|
81
99
|
```sh
|
|
82
100
|
pre-commit install
|
|
83
101
|
```
|
|
102
|
+
|
|
103
|
+
### To run on py.cafe
|
|
104
|
+
|
|
105
|
+
Build the application as a wheel, excluding dependencies:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
pip wheel . --no-deps
|
|
109
|
+
```
|