Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
CSE357 -Assignment 1
Overview
Goals.
· Practice probabilistic thinking and programming
· Utilize the concept of independence with conditional probabilities
General Requirements. Half of the assignment is a written mathematical and critical thinking exercise. This should be submitted as a pdf document with 1in margins all around (can be clearly hand-written or typed.).
The other half is a python assignment. You must use Python version 3.7 or later. You may integrate any code.
Python Libraries. No libraries beyond those listed below are permitted. Of these libraries, you may not use any subcomponents that specifically implement a concept which the instructions indicate you should implement. The project can be complete without any additional libraries. However, if any additional libraries are deemed permissible they will be listed here:
numpy as np
scipy.stats as ss
matplotlib.pyplot as plt
csv
Submission.
1. Title your pdf: a1_<lastname>_<id>.pdf.
2. Place all of your code in a single file, a1_<lastname>_<id>.py.
Your code should run with:
python3 a1_LASTNAME_ID.py
3. Place the output of your code in a single file called a1_<lastname>_<id>_OUTPUT.txt
Tip: After the package imports add the following line which sends your print() statements to a file instead of the console
sys.stdout = open('a1_lastname_id_OUTPUT.txt', 'w')
Change the file name to include your personal details. If this causes you any issues you can
also use '>' to redirect your results to a text file from your terminal or copy-and-paste your results into the .txt file
4. Submit all three of the .pdf, .py, and .txt in Blackboard under Assignment 1.
DO NOT ZIP the files, submit them as 3 independent files.
Academic Integrity. Copying chunks of code or writing from other students, websites or other resources outside of materials provided in class is prohibited. You are responsible for both (1) not copying others' work, and (2) making sure your work is not accessible to others. Assignments will be extensively checked for copying of others’ work. Please see the syllabus for additional policies.
Part I. Written (or typed) work. (40 points)
1. Dice Dependence (16 points). You roll two fair 6-sided dice (D1 and D2).
a) Which of the following are independent?
D1 = 6 and D1 + D2 = 5
D1 = 5 and D1 + D2 = 6
D1 = 4 and D1 + D2 = 7
None of the above
b) Why? (show your work)
2. Conditionally Independent Mining? (24 points) Suppose you are given five mines that may or may not contain gold, and based on stories you hear of all mines in the area you assume there is a 50% probability that any single mine has gold.
1. Under this assumption, what is the probability that all five mines have gold?
2. Suppose you learn that at least one mine has gold. Given only this additional information, what is the probability that all five contain gold? (show your work)
3. Your friend is also given 5 mines (ignore all information above). They are all along a road leading out of town. You learn that only one of these mines has gold. Your friend knows which mine it is and asks you to guess, suggesting he might share some of it if you get it right (fun friend!). You guess the mine closest to town, what is the probability that you are right?
Annoyingly, your friend won’t tell you whether you’re right! Instead, he reveals that it’s not the mine furthest from town. Should you change your answer? Why or why not? (explain probabilistically)
Part II. Programming.(60 points)
1. Simulated Dice Dependence. Program a simulation of problem 1 from Part I: rolling 2 fair-sided dice and evaluating whether the outcome of the first roll, D1, and the outcome of both rolls, D1 + D2, are independent. A fair-sided dice can be modeled as a discrete random variable with 6 possible outcomes in a uniform distribution. Your simulation should have an appropriate number of trials (i.e. rolls of both dice) to be able to conclude that D1 and (D1 + D2) appear independent.
Hint: Because we can't do infinitely many trials, we will say that two estimated probabilities (i.e. those from counting occurrences of events): P(X1) and P(X2) are equal if they are within .01 of each other: |P(X1) - P(X2)| <= .01.
Output note (added 9/16/2021):
You only need to print the probabilities associated with the events in parti I.1 answers.
1. Avoiding the death of your phone. Assume battery-life of an iphone is well-approximated by a normal distribution with μ = 42 hours and �� = 8.5 hours (assume lower-power options disabled).
1. Define the random variable in scipystats, and graph its pdf and cdf using matplotlib. Make sure to choose a reasonable range of x values.
2. Your friend wants to meet in exactly 6 hours, but they are not sure where exactly so she will text you 30 minutes before the meeting. You last charged your phone 34 hours ago. Use your random variable for battery life to find the probability that your phone will die before your friend sends the text. Print the probability to the screen as well as the pdf density value.
P(hour_phone_dies < hour_friend_txts) = .???
density(hour_friend_txts) = ?.??
3. You decide it’s too risky to chance your phone dying before receiving the text. You insist your friend text you sooner. You want to be 95% confident that your phone is not dead before she texts (i.e. you want P(phone_dies) < .05) ; In how many hours should you insist she texts by? Remember the current time is 34 hours since you last charged your phone and you can assume the phone has already survived this long. .
The friend should text by hour ??.??
4. You think you’ll hangout with your friend for 2.5 hours. Assume you received the text by the hour you found in 2.c, what is the probability that the phone dies while you are hanging out with your friend? Print the probability along with a CDF plot with the x-axis spanning the 2.5 hours you are hanging out with the friend
P(hangout_start < hour_phone_dies < hangout_end | received_txt) = .???
1. Your own random number generator.
The pdf function for the Kumaraswamy distribution is:
and cdf is:
(Thanks, Wikipedia)
a. Create your own random number generator from a Kumaraswamy distribution using only a single call to np.random.random_sample (no other libraries may be used, just mathematical functions).
def randKumaraswamy(size = 100, a = 2, b = 2):
#returns a list of size of random numbers drawn from a Kumaraswamy(a, b) distribution
uniform_sample = np.random.random_sample(100)
...
2. b. Create a kernel density estimation (KDE) plot of the resulting 100 random numbers from part a. You may use ss.gaussian_kde.