diff --git a/content/04_111_model.ipynb b/content/04_111_model.ipynb index ad12b53..4ac9c27 100644 --- a/content/04_111_model.ipynb +++ b/content/04_111_model.ipynb @@ -102,21 +102,21 @@ " Simulates the service process for a call operator\n", "\n", " 1. request and wait for a call operator\n", - " 2. phone triage (triangular)\n", + " 2. phone triage (triangular distribution)\n", " 3. exit system\n", " \n", " Params:\n", " ------\n", " \n", " identifier: int \n", - " A unique identifer for this caller\n", + " A unique identifier for this caller\n", " \n", " operators: simpy.Resource\n", " The pool of call operators that answer calls\n", " These are shared across resources.\n", " \n", " env: simpy.Environment\n", - " The current environent the simulation is running in\n", + " The current environment the simulation is running in\n", " We use this to pause and restart the process after a delay.\n", "\n", " service_rng: numpy.random.Generator\n", diff --git a/content/05_basic_results.ipynb b/content/05_basic_results.ipynb index 5816187..bff6a0a 100644 --- a/content/05_basic_results.ipynb +++ b/content/05_basic_results.ipynb @@ -142,21 +142,21 @@ " Simulates the service process for a call operator\n", "\n", " 1. request and wait for a call operator\n", - " 2. phone triage (triangular)\n", + " 2. phone triage (triangular distribution)\n", " 3. exit system\n", " \n", " Params:\n", " ------\n", " \n", " identifier: int \n", - " A unique identifer for this caller\n", + " A unique identifier for this caller\n", " \n", " operators: simpy.Resource\n", " The pool of call operators that answer calls\n", " These are shared across resources.\n", " \n", " env: simpy.Environment\n", - " The current environent the simulation is running in\n", + " The current environment the simulation is running in\n", " We use this to pause and restart the process after a delay.\n", "\n", " service_rng: numpy.random.Generator\n", diff --git a/content/06a_basic_results_exercise.ipynb b/content/06a_basic_results_exercise.ipynb index 71fd4d3..0cc0979 100644 --- a/content/06a_basic_results_exercise.ipynb +++ b/content/06a_basic_results_exercise.ipynb @@ -154,14 +154,14 @@ " ------\n", " \n", " identifier: int \n", - " A unique identifer for this caller\n", + " A unique identifier for this caller\n", " \n", " operators: simpy.Resource\n", " The pool of call operators that answer calls\n", " These are shared across resources.\n", " \n", " env: simpy.Environment\n", - " The current environent the simulation is running in\n", + " The current environment the simulation is running in\n", " We use this to pause and restart the process after a delay.\n", " \n", " '''\n", diff --git a/content/06b_basic_results_solutions.ipynb b/content/06b_basic_results_solutions.ipynb index 4e47375..f3a67d3 100644 --- a/content/06b_basic_results_solutions.ipynb +++ b/content/06b_basic_results_solutions.ipynb @@ -150,14 +150,14 @@ " ------\n", " \n", " identifier: int \n", - " A unique identifer for this caller\n", + " A unique identifier for this caller\n", " \n", " operators: simpy.Resource\n", " The pool of call operators that answer calls\n", " These are shared across resources.\n", " \n", " env: simpy.Environment\n", - " The current environent the simulation is running in\n", + " The current environment the simulation is running in\n", " We use this to pause and restart the process after a delay.\n", " \n", " '''\n", diff --git a/content/07_experiments.ipynb b/content/07_experiments.ipynb index 03c71f3..9641a73 100644 --- a/content/07_experiments.ipynb +++ b/content/07_experiments.ipynb @@ -19,7 +19,7 @@ "\n", "All of these approaches work well and it really is a matter of judgement on what you prefer. One downside of a python `dict` and a custom class is that they are both mutable (although a class can have custom properties where users can only access 'viewable' attributes). A dataclass can easily be made immutable and requires less code than a custom class, but has the downside that its syntax is a little less pythonic. Here we will build a parameter class called `Experiment`. \n", "\n", - "> ☺️ We will also use this re-organisation of code to elimiate our global variables!" + "> ☺️ We will also use this re-organisation of code to eliminate our global variables!" ] }, { @@ -75,7 +75,7 @@ "N_STREAMS = 2\n", "DEFAULT_RND_SET = 0\n", "\n", - "# Boolean switch to simulation results as the model runs\n", + "# Boolean switch to display simulation results as the model runs\n", "TRACE = False\n", "\n", "# run variables\n", @@ -217,7 +217,7 @@ " An Experiment:\n", " 1. Contains a list of parameters that can be left as defaults or varied\n", " 2. Provides a place for the experimentor to record results of a run \n", - " 3. Controls the set & streams of psuedo random numbers used in a run.\n", + " 3. Controls the set & streams of pseudo random numbers used in a run.\n", " \n", " \"\"\"\n", "\n", @@ -442,10 +442,10 @@ " ------\n", "\n", " identifier: int\n", - " A unique identifer for this caller\n", + " A unique identifier for this caller\n", "\n", " env: simpy.Environment\n", - " The current environent the simulation is running in\n", + " The current environment the simulation is running in\n", " We use this to pause and restart the process after a delay.\n", "\n", " args: Experiment\n", diff --git a/content/08_full_model.ipynb b/content/08_full_model.ipynb index 6fbfc85..9682071 100644 --- a/content/08_full_model.ipynb +++ b/content/08_full_model.ipynb @@ -95,7 +95,7 @@ "DEFAULT_RND_SET = 0\n", "# ##############################################################################\n", "\n", - "# Boolean switch to simulation results as the model runs\n", + "# Boolean switch to display simulation results as the model runs\n", "TRACE = False\n", "\n", "# run variables\n", @@ -349,7 +349,7 @@ " An Experiment:\n", " 1. Contains a list of parameters that can be left as defaults or varied\n", " 2. Provides a place for the experimentor to record results of a run\n", - " 3. Controls the set & streams of psuedo random numbers used in a run.\n", + " 3. Controls the set & streams of pseudo random numbers used in a run.\n", "\n", " \"\"\"\n", "\n", @@ -566,10 +566,10 @@ " Params:\n", " ------\n", " identifier: int\n", - " A unique identifer for this caller\n", + " A unique identifier for this caller\n", "\n", " env: simpy.Environment\n", - " The current environent the simulation is running in\n", + " The current environment the simulation is running in\n", " We use this to pause and restart the process after a delay.\n", "\n", " args: Experiment\n", diff --git a/content/09_time_weighted_calcs.ipynb b/content/09_time_weighted_calcs.ipynb index 4fc75c7..2f9fb92 100644 --- a/content/09_time_weighted_calcs.ipynb +++ b/content/09_time_weighted_calcs.ipynb @@ -95,7 +95,7 @@ "DEFAULT_RND_SET = 0\n", "# ##############################################################################\n", "\n", - "# Boolean switch to simulation results as the model runs\n", + "# Boolean switch to display simulation results as the model runs\n", "TRACE = False\n", "\n", "# run variables\n", @@ -423,7 +423,7 @@ " An Experiment:\n", " 1. Contains a list of parameters that can be left as defaults or varied\n", " 2. Provides a place for the experimentor to record results of a run\n", - " 3. Controls the set & streams of psuedo random numbers used in a run.\n", + " 3. Controls the set & streams of pseudo random numbers used in a run.\n", "\n", " \"\"\"\n", "\n", @@ -648,10 +648,10 @@ " Params:\n", " ------\n", " identifier: int\n", - " A unique identifer for this caller\n", + " A unique identifier for this caller\n", "\n", " env: simpy.Environment\n", - " The current environent the simulation is running in\n", + " The current environment the simulation is running in\n", " We use this to pause and restart the process after a delay.\n", "\n", " args: Experiment\n", diff --git a/content/10_multiple_arrival_processes.ipynb b/content/10_multiple_arrival_processes.ipynb index a2712a0..522c90e 100644 --- a/content/10_multiple_arrival_processes.ipynb +++ b/content/10_multiple_arrival_processes.ipynb @@ -67,7 +67,7 @@ "N_STREAMS = 4\n", "DEFAULT_RND_SET = 0\n", "\n", - "# Boolean switch to simulation results as the model runs\n", + "# Boolean switch to display simulation results as the model runs\n", "TRACE = False\n", "\n", "# run variables (units = hours)\n", @@ -79,7 +79,7 @@ "id": "5f2a4ad9-6d5e-480d-850f-84d4882a738b", "metadata": {}, "source": [ - "## 2. Helper classes and functions" + "## 3. Helper classes and functions" ] }, { @@ -153,7 +153,7 @@ "id": "5a8c050c-4bb6-408f-a805-3a4aaab56916", "metadata": {}, "source": [ - "## 3. Experiment class" + "## 4. Experiment class" ] }, { @@ -257,7 +257,7 @@ "id": "de8990c2-a330-4c02-ac77-26c30d3e0a41", "metadata": {}, "source": [ - "## 4. A function per arrival source\n", + "## 5. A function per arrival source\n", "\n", "The first approach we will use is creating an arrival generator per source. There will be some code redundancy, but it will a clear design for others to understand." ] @@ -392,7 +392,7 @@ "id": "6058571e-9fdb-4961-be27-8a3b8c2fe26e", "metadata": {}, "source": [ - "## 5. Single run function" + "## 6. Single run function" ] }, { diff --git a/content/11_blocking.ipynb b/content/11_blocking.ipynb index 2343aab..73c00bd 100644 --- a/content/11_blocking.ipynb +++ b/content/11_blocking.ipynb @@ -82,7 +82,7 @@ "N_STREAMS = 3\n", "DEFAULT_RND_SET = 0\n", "\n", - "# Boolean switch to simulation results as the model runs\n", + "# Boolean switch to display simulation results as the model runs\n", "TRACE = False\n", "\n", "# run variables (units = days)\n", @@ -94,7 +94,7 @@ "id": "5f2a4ad9-6d5e-480d-850f-84d4882a738b", "metadata": {}, "source": [ - "## 2. Helper classes and functions" + "## 3. Helper classes and functions" ] }, { @@ -122,7 +122,7 @@ "id": "5a8c050c-4bb6-408f-a805-3a4aaab56916", "metadata": {}, "source": [ - "## 3. Experiment class" + "## 4. Experiment class" ] }, { @@ -229,7 +229,7 @@ "id": "94f0f9c5-22cb-493a-9f1f-4e2a8325beaa", "metadata": {}, "source": [ - "## 4. Pathway process logic\n", + "## 5. Pathway process logic\n", "\n", "The key things to recognise are \n", "\n", @@ -317,7 +317,7 @@ "id": "de8990c2-a330-4c02-ac77-26c30d3e0a41", "metadata": {}, "source": [ - "## 4. Arrivals generator\n", + "## 6. Arrivals generator\n", "\n", "This is a standard arrivals generator. We create stroke arrivals according to their distribution." ] @@ -362,7 +362,7 @@ "id": "6058571e-9fdb-4961-be27-8a3b8c2fe26e", "metadata": {}, "source": [ - "## 5. Single run function" + "## 7. Single run function" ] }, { diff --git a/content/12_arrival_classes.ipynb b/content/12_arrival_classes.ipynb index 774e979..2693909 100644 --- a/content/12_arrival_classes.ipynb +++ b/content/12_arrival_classes.ipynb @@ -92,7 +92,7 @@ "N_STREAMS = 4\n", "DEFAULT_RND_SET = 0\n", "\n", - "# Boolean switch to simulation results as the model runs\n", + "# Boolean switch to display simulation results as the model runs\n", "TRACE = False\n", "\n", "# run variables (units = minutes)\n", diff --git a/content/13_warm_up.ipynb b/content/13_warm_up.ipynb index c3ea9cc..ddd6971 100644 --- a/content/13_warm_up.ipynb +++ b/content/13_warm_up.ipynb @@ -91,7 +91,7 @@ "N_STREAMS = 2\n", "DEFAULT_RND_SET = 0\n", "\n", - "# Boolean switch to simulation results as the model runs\n", + "# Boolean switch to display simulation results as the model runs\n", "TRACE = False\n", "\n", "# run variables (units = days)\n", diff --git a/content/14_initial_conditions.ipynb b/content/14_initial_conditions.ipynb index 45e9167..4cac409 100644 --- a/content/14_initial_conditions.ipynb +++ b/content/14_initial_conditions.ipynb @@ -124,7 +124,7 @@ "N_STREAMS = 3\n", "DEFAULT_RND_SET = 0\n", "\n", - "# Boolean switch to simulation results as the model runs\n", + "# Boolean switch to display simulation results as the model runs\n", "TRACE = False\n", "\n", "# run variables (units = days)\n", diff --git a/content/basic_model.py b/content/basic_model.py index 16a6536..a433784 100644 --- a/content/basic_model.py +++ b/content/basic_model.py @@ -142,7 +142,7 @@ class Experiment: An Experiment: 1. Contains a list of parameters that can be left as defaults or varied 2. Provides a place for the experimentor to record results of a run - 3. Controls the set & streams of psuedo random numbers used in a run. + 3. Controls the set & streams of pseudo random numbers used in a run. """ def __init__( @@ -261,10 +261,10 @@ def service(identifier, env, args): Params: ------ identifier: int - A unique identifer for this caller + A unique identifier for this caller env: simpy.Environment - The current environent the simulation is running in + The current environment the simulation is running in We use this to pause and restart the process after a delay. args: Experiment diff --git a/content/distributions.py b/content/distributions.py index fc2e943..c28d45d 100644 --- a/content/distributions.py +++ b/content/distributions.py @@ -1,5 +1,5 @@ """ -Distribution and utility classes avilable to these examples. +Distribution and utility classes available to these examples. """ import numpy as np @@ -142,50 +142,6 @@ def sample(self, size=None): """ return self.rand.exponential(self.mean, size=size) - -class Bernoulli: - """ - Convenience class for the Bernoulli distribution. - packages up distribution parameters, seed and random generator. - - The Bernoulli distribution is a special case of the binomial distribution - where a single trial is conducted - - Use the Bernoulli distribution to sample success or failure. - """ - - def __init__(self, p, random_seed=None): - """ - Constructor - - Params: - ------ - p: float - probability of drawing a 1 - - random_seed: int | SeedSequence, optional (default=None) - A random seed to reproduce samples. If set to none then a unique - sample is created. - """ - self.rand = np.random.default_rng(seed=random_seed) - self.p = p - - def sample(self, size=None): - """ - Generate a sample from the exponential distribution - - Params: - ------- - size: int, optional (default=None) - the number of samples to return. If size=None then a single - sample is returned. - - Returns: - ------- - float or np.ndarray (if size >=1) - """ - return self.rand.binomial(n=1, p=self.p, size=size) - class DiscreteEmpirical: """ DiscreteEmpirical distribution implementation.