#!/usr/bin/env python # coding: utf-8 # # Practice Problems # ### Lecture 15 # Answer each number in a separate cell # # Rename this notebook with your last name and the lecture # # ex. Cych_B_15 # # Turn-in this notebook on Canvas # ## 1. Binomial functions # - 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$). # - Calculate the probability of purchasing one winning lottery ticket. # - Create a list of probabilites. The probability of purchasing 1 winning ticket, 2 winning tickets, 3 winning tickets, ... up to 10 winning tickets. # - Plot the probability against the number of winning tickets purchased as a green bar plot. Label both axes # # # ## 2. Monte Carlo simulations with stats.binom( ) # - 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$). # - Run 100 simulations ($Nmc$) of the scenario # - Plot the simulated results as a histogram and the theoretical distribution as a line graph # - Add a title to the plot # - Add a legend # - Add a label to the x-axis and y-axis # # # ## 3. Uniform distributions # # - 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) # - Perform a Monte Carlo simulation with $n=30$ trials. # - Plot your theoretical and simulated results as a bar and histogram plot respectively. # - Try this again using the random.seed() function. # # ## 4. Normal distributions # - Calculate the theoretical distribution of grades on an exam with a mean of 50% and a standard deviation of $\pm$ 20. # - Simulate the results of an exam taken by 35 students # - Calculate the mean and standard deviation of your simulated results. # - Plot theoretical and simulated results as a bar graph and histogram respectively. # - Plot a solid line representing the cutoffs for As, Bs, Cs, Ds, and Fs # - Add a title, x-label, y-label, and legend # # # 5. Log-normal distributions # - 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. # - Plot the distribution as a histogram (density set to True). # - Calculate the mean, standard deviation, expectation and variance of the distribution. # In[ ]: