|
121 | 121 | "cell_type": "markdown", |
122 | 122 | "metadata": {}, |
123 | 123 | "source": [ |
124 | | - "### Exercise 1: <a name=\"back1\"></a>First histogram\n", |
| 124 | + "### Exercise 1: <a id=\"back1\"></a>First histogram\n", |
125 | 125 | "Generate 1000 random numbers from a Normal distribution with mean 100 and standard deviation 10. Compute and print to the screen the mean and standard deviation of your data. Create two graphs above each other using the `plt.subplot` command. In the top graph, plot a histogram using 20 bins going from 50 to 150. Note that with this size of a data set (1000 data points), the histogram starts to look a lot more like the typical bell-shaped curve of a Normal distribution. Add a red line representing the probability density function of the underlying normal distribution to the graph. In the bottom graph, draw a histogram of the cumulative distribution function, by setting the keyword `cumulative=True` (see `plt.hist?` for details). For the latter graph, use the keyword `align='right'` so that the bars are centered on the right bin edges (so that the line you are drawing next will approximately go through the centers of the bars). Add a red line representing the cumulative distribution function of the underlying normal distribution to the graph using the `norm.cdf` function, which works the same as the `norm.pdf` function but computes the cumulative distribution function (cdf). Finally, make sure the limits along the horizontal axis are the same for both graphs. " |
126 | 126 | ] |
127 | 127 | }, |
|
181 | 181 | "cell_type": "markdown", |
182 | 182 | "metadata": {}, |
183 | 183 | "source": [ |
184 | | - "### Expercise 2. <a name=\"back2\"></a>Lower and upper quartile\n", |
| 184 | + "### Expercise 2. <a id=\"back2\"></a>Lower and upper quartile\n", |
185 | 185 | "Generate 100 data points from a normal distribution with a mean of 20 and a standard deviation of 4. Compute the interquartile range (25%-75% range). Compute the theoretical value of the interquartile range and compare it to the interquartile range of the data. Draw a histogram of the cumulative distribution. Add red vertical lines to your graph for the 0.25 and 0.75 empirical quantiles of the data, and black vertical lines for the 0.25 and 0.75 quantiles of the underlying distribution. Vertical lines that span the graph may be added with the `plt.axvline` function, which takes the $x$ value of the line as an argument. To specify the color of the vertical line, use the `color` keyword argument." |
186 | 186 | ] |
187 | 187 | }, |
|
391 | 391 | "cell_type": "markdown", |
392 | 392 | "metadata": {}, |
393 | 393 | "source": [ |
394 | | - "### Exercise 3. <a name=\"back3\"></a>Loading experimental data and basic operations\n", |
| 394 | + "### Exercise 3. <a id=\"back3\"></a>Loading experimental data and basic operations\n", |
395 | 395 | "Load the data in the file `douglas_data.csv` using the `read_csv` command of the `pandas` package (see the `pandas` Notebook if you forgot how). Use the `skiprows` and `skipinitialspace` keywords. Carry out the following three tasks:\n", |
396 | 396 | "\n", |
397 | 397 | "* Determine and report the minimum and maximum measured values of the bending strength. \n", |
|
417 | 417 | "cell_type": "markdown", |
418 | 418 | "metadata": {}, |
419 | 419 | "source": [ |
420 | | - "### Exercise 4. <a name=\"back4\"></a>Boxplot of moisture content\n", |
| 420 | + "### Exercise 4. <a id=\"back4\"></a>Boxplot of moisture content\n", |
421 | 421 | "The moisture content is defined as the mass of moisture in a beam divided by the total mass of the beam (including the moisture) and is recorded as a percentage. Compute and report the mean and standard deviation of the moisture content, and make a box plot." |
422 | 422 | ] |
423 | 423 | }, |
|
453 | 453 | "cell_type": "markdown", |
454 | 454 | "metadata": {}, |
455 | 455 | "source": [ |
456 | | - "### Exercise 5. <a name=\"back5\"></a>Histogram of bending strength\n", |
| 456 | + "### Exercise 5. <a id=\"back5\"></a>Histogram of bending strength\n", |
457 | 457 | "Create a histogram of the bending strength. Add labels to the axes. Does the histogram look like a Normal distribution? On the same graph draw a red vertical line for the experimentally determined 5% bending strength. Print the 0.05 experimental quantile bending strength to the screen." |
458 | 458 | ] |
459 | 459 | }, |
|
475 | 475 | "cell_type": "markdown", |
476 | 476 | "metadata": {}, |
477 | 477 | "source": [ |
478 | | - "### Exercise 6. <a name=\"back6\"></a>Normal distribution for bending strength\n", |
| 478 | + "### Exercise 6. <a id=\"back6\"></a>Normal distribution for bending strength\n", |
479 | 479 | "Let's try to fit a normal distribution to the bending strength data. This is obviously not quite correct, as the tail of the Normal distribution will extend below zero to the left, which is unrealistic. If the part of the tail below zero is small, it may be a reasonable first step. Create a normalized histogram of the bending strength. Compute the mean and standard deviation of the bending strength data and plot on the same graph the Normal probability density function using these estimates of the mean and standard deviation. Add a red vertical line for the 5% bending strength according to the data, and a black vertical line for the 5% bending strength according to the fitted Normal distribution" |
480 | 480 | ] |
481 | 481 | }, |
|
504 | 504 | "cell_type": "markdown", |
505 | 505 | "metadata": {}, |
506 | 506 | "source": [ |
507 | | - "<a name=\"ex1answer\">Answers to Exercise 1</a>" |
| 507 | + "<a id=\"ex1answer\">Answers to Exercise 1</a>" |
508 | 508 | ] |
509 | 509 | }, |
510 | 510 | { |
|
542 | 542 | "source": [ |
543 | 543 | "<a href=\"#back1\">Back to Exercise 1</a>\n", |
544 | 544 | "\n", |
545 | | - "<a name=\"ex2answer\">Answers to Exercise 2</a>" |
| 545 | + "<a id=\"ex2answer\">Answers to Exercise 2</a>" |
546 | 546 | ] |
547 | 547 | }, |
548 | 548 | { |
|
573 | 573 | "source": [ |
574 | 574 | "<a href=\"#back2\">Back to Exercise 2</a>\n", |
575 | 575 | "\n", |
576 | | - "<a name=\"ex3answer\">Answers to Exercise 3</a>" |
| 576 | + "<a id=\"ex3answer\">Answers to Exercise 3</a>" |
577 | 577 | ] |
578 | 578 | }, |
579 | 579 | { |
|
596 | 596 | "source": [ |
597 | 597 | "<a href=\"#back3\">Back to Exercise 3</a>\n", |
598 | 598 | "\n", |
599 | | - "<a name=\"ex4answer\">Answers to Exercise 4</a>" |
| 599 | + "<a id=\"ex4answer\">Answers to Exercise 4</a>" |
600 | 600 | ] |
601 | 601 | }, |
602 | 602 | { |
|
626 | 626 | "source": [ |
627 | 627 | "<a href=\"#back4\">Back to Exercise 4</a>\n", |
628 | 628 | "\n", |
629 | | - "<a name=\"ex5answer\">Answers to Exercise 5</a>" |
| 629 | + "<a id=\"ex5answer\">Answers to Exercise 5</a>" |
630 | 630 | ] |
631 | 631 | }, |
632 | 632 | { |
|
648 | 648 | "source": [ |
649 | 649 | "<a href=\"#back5\">Back to Exercise 5</a>\n", |
650 | 650 | "\n", |
651 | | - "<a name=\"ex6answer\">Answers to Exercise 6</a>" |
| 651 | + "<a id=\"ex6answer\">Answers to Exercise 6</a>" |
652 | 652 | ] |
653 | 653 | }, |
654 | 654 | { |
|
0 commit comments