From 58185c0ab90d76f4f451c55a2591001d7ec0cde4 Mon Sep 17 00:00:00 2001 From: Stella Schultz Date: Tue, 1 Jul 2025 15:04:17 -0400 Subject: [PATCH 1/4] fix typos in TOC/simulation section, added skeleton for book intro and simulation overview, restructured simulation sections --- book/_toc.yml | 4 ++-- book/intro.md | 13 +++++++++++++ book/simulation/Birth_Month_Simulation.ipynb | 11 +++++++---- book/simulation/Simulating_Dice.ipynb | 20 ++++++++++++++------ book/simulation/overview.md | 6 ++++-- 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/book/_toc.yml b/book/_toc.yml index e83a25e..9a3346a 100644 --- a/book/_toc.yml +++ b/book/_toc.yml @@ -2,13 +2,13 @@ format: jb-book root: intro.md parts: - - caption: Subjects + - caption: Contents chapters: - file: simulation/overview.md sections: - file: simulation/Simulating_Dice.ipynb - file: simulation/Birth_Month_Simulation.ipynb - - caption: Miscallaneous + - caption: Miscellaneous chapters: - file: references.md #- file: changelog.md diff --git a/book/intro.md b/book/intro.md index 38a7b66..765ec64 100644 --- a/book/intro.md +++ b/book/intro.md @@ -1,3 +1,16 @@ (intro)= # Probability and Statistics - Code Companion This online book is designed to complement the Probability and Statistics courses taught at TU Delft. It explains how the visualisations and data analyses used in the course were created and guides you in making your own. + +```{tip} +You can interact with coding sections of the book by clicking the rocket icon ({fa}`rocket`) found in the top right of the page. +``` + +## Additional Resources + +## Reporting Mistakes + +## Questions and Answers + +## Book Layout + diff --git a/book/simulation/Birth_Month_Simulation.ipynb b/book/simulation/Birth_Month_Simulation.ipynb index 5dd8192..1c21191 100644 --- a/book/simulation/Birth_Month_Simulation.ipynb +++ b/book/simulation/Birth_Month_Simulation.ipynb @@ -6,7 +6,8 @@ "source": [ "# Birth Month Simulation\n", "\n", - "We can use the built in random choice feature of numpy to simulate non-uniformly distributed events. For instance below we consider the situation where we want to simulate the choice of a costumer at a chips shop. The costumer can chooce to have mayonaise, ketchup, curry or peanut sauce on their chips. We simulate the choice the costumer makes by assigning each choice a certain probability. " + "## Chips Shop Order Choice\n", + "We can use the built in random choice feature of [numpy](https://numpy.org/doc/) to simulate non-uniformly distributed events. For instance, below we consider the situation where we want to simulate the choice of a customer at a chips shop. The customer can choose to have mayonnaise, ketchup, curry or peanut sauce on their chips. We simulate the choice the costumer makes by assigning each choice a certain probability. " ] }, { @@ -42,7 +43,7 @@ "metadata": {}, "outputs": [], "source": [ - "food = [\"mayonaise\", \"ketchup\", \"curry\", \"peanut sauce\"]\n", + "food = [\"mayonnaise\", \"ketchup\", \"curry\", \"peanut sauce\"]\n", "p = [0.6, 0.1, 0.15, 0.15]\n", "food_choice = np.random.choice(food, p=p)\n", "print(food_choice)" @@ -52,7 +53,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now let's consider simulation of the birth months. So we will simulate a town of people together with their birth months. We use three different models for the birth months distributions. Namely, the uniform distribution over months, a uniform model over days that does not take leap days into account and a uniform model over days that does take leap days into account. " + "## Birth Month\n", + "\n", + "Now let's consider simulation of the birth months. We will simulate a town of people together with their birth months. We use three different models for the birth months distributions. Namely, the uniform distribution over months, a uniform model over days that does not take leap days into account and a uniform model over days that does take leap days into account. " ] }, { @@ -117,7 +120,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Finally let's have a look at our simulated distribution. For more on plotting have a look at the visualiation chapter. Below we load our simulated data into a dataframe and subsquently plot the proportions of each model into a histogram. " + "Finally let's have a look at our simulated distribution. For more on plotting have a look at the visualization chapter. Below we load our simulated data into a dataframe and subsequently plot the proportions of each model into a histogram. " ] }, { diff --git a/book/simulation/Simulating_Dice.ipynb b/book/simulation/Simulating_Dice.ipynb index 9319dd2..ddcde33 100644 --- a/book/simulation/Simulating_Dice.ipynb +++ b/book/simulation/Simulating_Dice.ipynb @@ -33,7 +33,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - " The most basic building blocks are uniform random variables. We will gloss over the mechanics of how random number generators are produced and simply call them, using the `numpy` package. \n", + " ## Uniform Random Variables\n", + " \n", + " The most basic building blocks are uniform random variables. We will gloss over the mechanics of how random number generators are produced and simply call them, using the [`numpy`](https://numpy.org/doc/) package. \n", "Below is our first simulated $X\\sim U(0,1)$ random variable. " ] }, @@ -52,9 +54,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The function np.random.uniform can be supplied two parameters, a lower limit and an upper limit, which are by default set to $0$ and $1$. Above you can enter these parameter to produce instead a uniformly distributed real number between for instance $-1$ and $4$ by entering $-1, 4$ in the brackets. \n", + "The function `np.random.uniform` can be supplied two parameters, a lower limit ($\\alpha$) and an upper limit ($\\beta$), which are by default set to $0$ and $1$. You can enter these parameter to produce a uniformly distributed real number between $\\alpha$ and $\\beta$. For instance, you can produce a unfiromly distributed real number between $-1$ and $4$ using the following line of code:\n", "\n", - "We can use this uniformly distributed random variable to simulate various other distributions. For instance we may simulate a six sided die:" + "```python\n", + "np.random.uniform(-1,4)\n", + "```\n", + "\n", + "We can use this uniformly distributed random variable to simulate various other distributions. For instance we may simulate a six-sided die:" ] }, { @@ -72,9 +78,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Indeed in the code above we randomly generate a uniformly distributed number between 1 and 7 then round down to the nearest integer, which produces a(n ideal) die. You may want to try to change the code to simulate a $4$ or $8$ sided die. \n", + "Indeed in the code above we randomly generate a uniformly distributed number between $1$ and $7$ then round down to the nearest integer, which produces a(n ideal) die. You may want to try to change the code to simulate a $4$ or $8$ sided die. \n", + "\n", + "Very often we will need to simulate not one die, but many dice at the same time. The third parameter of the uniform distribution is the size. We may use this parameter to produce an array of many random numbers at once. Each random number is independently uniformly distributed. \n", "\n", - "Very often we will need to simulate not one die, but many dice at the same time. The third parameter of the uniform distribution is the size. We may use this parameter to produce an array of many random numbers at once. Each random number is independently uniformly distributed. " + "The code below simulates rolling a six-sided die ten times." ] }, { @@ -117,7 +125,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Finally we can now simulate not just individual die rolls, but also sums of dice rolls leading to simulations of non-uniformly distributed random variables. For example below we simulate many rolls of a pair of $4$ sided die rolls and check that we obtain the expected distribution of sums. " + "Finally we can now simulate not just individual die rolls, but also sums of dice rolls leading to simulations of non-uniformly distributed random variables. For example, below we simulate many rolls of a pair of four-sided die rolls and check that we obtain the expected distribution of sums. " ] }, { diff --git a/book/simulation/overview.md b/book/simulation/overview.md index fe4cf2c..9d4a0d1 100644 --- a/book/simulation/overview.md +++ b/book/simulation/overview.md @@ -1,5 +1,7 @@ # Simulation + -This is the file simulation/overview.md . -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \ No newline at end of file + +## Chapter Overview + \ No newline at end of file From 960602094b5efda1eb02edee75d396443849029f Mon Sep 17 00:00:00 2001 From: Stella Schultz Date: Wed, 2 Jul 2025 11:19:34 -0400 Subject: [PATCH 2/4] add explanation for chip shop example for clarity, update spelling to use American english --- book/intro.md | 2 +- book/simulation/Birth_Month_Simulation.ipynb | 15 +++++++++------ book/simulation/overview.md | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/book/intro.md b/book/intro.md index 765ec64..d8aafd5 100644 --- a/book/intro.md +++ b/book/intro.md @@ -1,6 +1,6 @@ (intro)= # Probability and Statistics - Code Companion -This online book is designed to complement the Probability and Statistics courses taught at TU Delft. It explains how the visualisations and data analyses used in the course were created and guides you in making your own. +This online book is designed to complement the Probability and Statistics courses taught at TU Delft. It explains how the visualizations and data analyses used in the course were created and guides you in making your own. ```{tip} You can interact with coding sections of the book by clicking the rocket icon ({fa}`rocket`) found in the top right of the page. diff --git a/book/simulation/Birth_Month_Simulation.ipynb b/book/simulation/Birth_Month_Simulation.ipynb index 1c21191..23d4fe8 100644 --- a/book/simulation/Birth_Month_Simulation.ipynb +++ b/book/simulation/Birth_Month_Simulation.ipynb @@ -6,8 +6,9 @@ "source": [ "# Birth Month Simulation\n", "\n", - "## Chips Shop Order Choice\n", - "We can use the built in random choice feature of [numpy](https://numpy.org/doc/) to simulate non-uniformly distributed events. For instance, below we consider the situation where we want to simulate the choice of a customer at a chips shop. The customer can choose to have mayonnaise, ketchup, curry or peanut sauce on their chips. We simulate the choice the costumer makes by assigning each choice a certain probability. " + "We can use the built in random choice feature of [numpy](https://numpy.org/doc/) to simulate non-uniformly distributed events. \n", + "\n", + "To illustrate the `np.random.choice` functionality, consider a toy example where we want to simulate the choice of a customer at a fries shop. The customer can choose to have mayonnaise, ketchup, curry or peanut sauce on their fries. We simulate the choice the customer makes by assigning each choice a certain probability. " ] }, { @@ -53,9 +54,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Birth Month\n", - "\n", - "Now let's consider simulation of the birth months. We will simulate a town of people together with their birth months. We use three different models for the birth months distributions. Namely, the uniform distribution over months, a uniform model over days that does not take leap days into account and a uniform model over days that does take leap days into account. " + "Now let's consider simulation of the birth months. We will simulate a town of people together with their birth months. We use three different models for the birth months distributions: the uniform distribution over months, a uniform model over days that does not take leap days into account, and a uniform model over days that does take leap days into account. " ] }, { @@ -120,7 +119,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Finally let's have a look at our simulated distribution. For more on plotting have a look at the visualization chapter. Below we load our simulated data into a dataframe and subsequently plot the proportions of each model into a histogram. " + "Finally let's have a look at our simulated distribution. Below we load our simulated data into a dataframe and subsequently plot the proportions of each model into a histogram. \n", + "\n", + "```{tip}\n", + "For more on plotting have a look at the visualization chapter.\n", + "```{tip}" ] }, { diff --git a/book/simulation/overview.md b/book/simulation/overview.md index 9d4a0d1..4cdcd18 100644 --- a/book/simulation/overview.md +++ b/book/simulation/overview.md @@ -1,7 +1,7 @@ # Simulation - + ## Chapter Overview - \ No newline at end of file + \ No newline at end of file From 1d5e200e8705098d35b557fb7c6d7b3b8630e915 Mon Sep 17 00:00:00 2001 From: Stella Schultz Date: Fri, 11 Jul 2025 12:10:56 -0400 Subject: [PATCH 3/4] switch american to british english and fix typo --- book/intro.md | 2 +- book/simulation/Birth_Month_Simulation.ipynb | 2 +- book/simulation/Simulating_Dice.ipynb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/book/intro.md b/book/intro.md index d8aafd5..765ec64 100644 --- a/book/intro.md +++ b/book/intro.md @@ -1,6 +1,6 @@ (intro)= # Probability and Statistics - Code Companion -This online book is designed to complement the Probability and Statistics courses taught at TU Delft. It explains how the visualizations and data analyses used in the course were created and guides you in making your own. +This online book is designed to complement the Probability and Statistics courses taught at TU Delft. It explains how the visualisations and data analyses used in the course were created and guides you in making your own. ```{tip} You can interact with coding sections of the book by clicking the rocket icon ({fa}`rocket`) found in the top right of the page. diff --git a/book/simulation/Birth_Month_Simulation.ipynb b/book/simulation/Birth_Month_Simulation.ipynb index 23d4fe8..bfd7079 100644 --- a/book/simulation/Birth_Month_Simulation.ipynb +++ b/book/simulation/Birth_Month_Simulation.ipynb @@ -122,7 +122,7 @@ "Finally let's have a look at our simulated distribution. Below we load our simulated data into a dataframe and subsequently plot the proportions of each model into a histogram. \n", "\n", "```{tip}\n", - "For more on plotting have a look at the visualization chapter.\n", + "For more on plotting have a look at the visualisation chapter.\n", "```{tip}" ] }, diff --git a/book/simulation/Simulating_Dice.ipynb b/book/simulation/Simulating_Dice.ipynb index ddcde33..7da0383 100644 --- a/book/simulation/Simulating_Dice.ipynb +++ b/book/simulation/Simulating_Dice.ipynb @@ -54,7 +54,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The function `np.random.uniform` can be supplied two parameters, a lower limit ($\\alpha$) and an upper limit ($\\beta$), which are by default set to $0$ and $1$. You can enter these parameter to produce a uniformly distributed real number between $\\alpha$ and $\\beta$. For instance, you can produce a unfiromly distributed real number between $-1$ and $4$ using the following line of code:\n", + "The function `np.random.uniform` can be supplied two parameters, a lower limit ($\\alpha$) and an upper limit ($\\beta$), which are by default set to $0$ and $1$. You can enter these parameter to produce a uniformly distributed real number between $\\alpha$ and $\\beta$. For instance, you can produce a uniformly distributed real number between $-1$ and $4$ using the following line of code:\n", "\n", "```python\n", "np.random.uniform(-1,4)\n", From c817ef9cf206c9f440d6907ad0ae0f7aacfe5dfe Mon Sep 17 00:00:00 2001 From: Stella Schultz Date: Fri, 26 Sep 2025 09:44:56 +0200 Subject: [PATCH 4/4] add citations for datasets --- book/_config.yml | 1 + book/references.bib | 46 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/book/_config.yml b/book/_config.yml index 9a14c9a..a74b4e6 100644 --- a/book/_config.yml +++ b/book/_config.yml @@ -50,6 +50,7 @@ sphinx: - sphinx_exercise - teachbooks_sphinx_grasple - sphinx_tudelft_theme + - sphinxcontrib.bibtex bibtex_bibfiles: - references.bib diff --git a/book/references.bib b/book/references.bib index 658a4ca..81e2461 100644 --- a/book/references.bib +++ b/book/references.bib @@ -1,6 +1,40 @@ -@misc{jason_moore, - title={Learn Multibody Dynamics, SymPy}, - author={Moore, Jason}, - howpublished={\url{https://moorepants.github.io/learn-multibody-dynamics/sympy.html}}, - year={2023} -} \ No newline at end of file +@misc{mysarahmadbhat_ford, + author = {mysarahmadbhat}, + title = {Ford Used Car Listing}, + howpublished = {Kaggle dataset}, + year = {n.d.}, + note = {Accessed: 2025-09-26} +} + +@misc{quinlan_1993_autompg, + author = {Quinlan, R.}, + title = {Auto MPG}, + howpublished = {UCI Machine Learning Repository}, + year = {1993}, + doi = {10.24432/C5859H}, + note = {Accessed: 2025-09-26} +} + +@misc{ukveteran_michelson, + author = {ukveteran}, + title = {Michelson --- Speed of Light Data}, + howpublished = {Kaggle dataset}, + year = {n.d.}, + note = {Accessed: 2025-09-26} +} + +@misc{cdc_brfss_2014, + author = {{Centers for Disease Control and Prevention}}, + title = {Behavioral Risk Factor Surveillance System --- 2014 data (ASCII \& SAS files)}, + howpublished = {U.S. Department of Health \& Human Services}, + year = {2015}, + note = {Accessed: 2025-09-26} +} + +@misc{uci_pima, + author = {{UCI Machine Learning Repository}}, + title = {Pima Indians Diabetes Database}, + howpublished = {University of California, Irvine}, + year = {n.d.}, + note = {Accessed: 2025-09-26} +}