{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Practice Problems\n", "### Lecture 15\n", "Answer each number in a separate cell\n", "\n", "Rename this notebook with your last name and the lecture \n", " \n", " ex. Cych_B_15\n", " \n", "Turn-in this notebook on Canvas" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Binomial functions\n", "- Assume that the probability of getting a winning lottery ticket ($p$) is 1 in 20 and you have money to purchase up to 10 tickets ($n$). \n", " - Calculate the probability of purchasing one winning lottery ticket. \n", " - Create a list of probabilites. The probability of purchasing 1 winning ticket, 2 winning tickets, 3 winning tickets, ... up to 10 winning tickets. \n", " - Plot the probability against the number of winning tickets purchased as a green bar plot. Label both axes\n", "\n", "\n", "## 2. Monte Carlo simulations with stats.binom( )\n", "- Again, assume that the probability of getting a winning lottery ticket ($p$) is 1 in 20 and you have money to purchase up to 10 tickets ($n$). \n", " - Run 100 simulations ($Nmc$) of the scenario \n", " - Plot the simulated results as a histogram and the theoretical distribution as a line graph\n", " - Add a title to the plot \n", " - Add a legend\n", " - Add a label to the x-axis and y-axis\n", "\n", "\n", "## 3. Uniform distributions\n", "\n", "- Calculate the theoretical distribution of getting a particular azimuth between 0 and 360 when measuring, for example, the direction of a strike - assume that each result is equally likely (a uniform distribution between 0 and 360) \n", "- Perform a Monte Carlo simulation with $n=30$ trials. \n", "- Plot your theoretical and simulated results as a bar and histogram plot respectively. \n", "- Try this again using the random.seed() function. \n", "\n", "## 4. Normal distributions\n", "- Calculate the theoretical distribution of grades on an exam with a mean of 50% and a standard deviation of $\\pm$ 20.\n", "- Simulate the results of an exam taken by 35 students\n", "- Calculate the mean and standard deviation of your simulated results. \n", "- Plot theoretical and simulated results as a bar graph and histogram respectively.\n", "- Plot a solid line representing the cutoffs for As, Bs, Cs, Ds, and Fs \n", "- Add a title, x-label, y-label, and legend\n", "\n", "# 5. Log-normal distributions\n", "- Simulate a grain size distribution that is drawn from a log normal distribution with 1000 grains and a mean and standard deviation of 10 and 0.1 microns respectively. \n", "- Plot the distribution as a histogram (density set to True).\n", "- Calculate the mean, standard deviation, expectation and variance of the distribution. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.7" } }, "nbformat": 4, "nbformat_minor": 2 }