联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> CS作业CS作业

日期:2018-10-11 09:51

2018/10/9 hw05

http://localhost:8888/nbconvert/html/CS237/hw05.ipynb?download=false 1/5

CS 237 Fall 2018, Homework 05

Due date: Thursday October 11th at 11:59 pm (10% off if up to 24 hours late) via

Gradescope

General Instructions

Please complete this notebook by filling in solutions where indicated. Be sure to "Run All" from the Cell

menu before submitting.

You may use ordinary ASCII text to write your solutions, or (preferably) Latex. A nice introduction to Latex in

Jupyter notebooks may be found here: http://data-blog.udacity.com/posts/2016/10/latex-primer/

(http://data-blog.udacity.com/posts/2016/10/latex-primer/)

As with previous homeworks, just upload a PDF file of this notebook. Instructions for converting to PDF may

be found on the class web page right under the link for homework 1.

2018/10/9 hw05

http://localhost:8888/nbconvert/html/CS237/hw05.ipynb?download=false 2/5

In[1]:

# Useful imports and definitions for CS 237

import numpy as np # arrays and functions which operate on array

from numpy import linspace, arange

import matplotlib.pyplot as plt # normal plotting

#import seaborn as sns # Fancy plotting

#import pandas as pd # Data input and manipulation

from random import random, randint, uniform, choice, sample, shuffle, seed

from collections import Counter

%matplotlib inline

# Calculating permutations and combinations efficiently

def P(N,K):

res = 1

for i in range(K):

res *= N

N = N - 1

return res


def C(N,K):

if(K < N/2):

K = N-K

X = [1]*(K+1)

for row in range(1,N-K+1):

X[row] *= 2

for col in range(row+1,K+1):

X[col] = X[col]+X[col-1]

return X[K]

# Round to 4 decimal places for printing numeric answers.

def round4(x):

return round(x+0.00000000001,4)

def round4_list(L):

return [ round4(x) for x in L]

HW 05 Instructions

Feel free to calculate the solutions using Python, using the code in the previous cell. Or use Wolfram

Alpha....

All of these problems involve the binomial!!

2018/10/9 hw05

http://localhost:8888/nbconvert/html/CS237/hw05.ipynb?download=false 3/5

Problem One

A restaurant serves 8 fish entrees, 12 beef, and 10 chicken. If customers select from these entrees randomly

and independently, and the kitchen has plenty of each entree (so this is "with replacement"), what is the

probability

(a) that at least 4 of the next 10 customers order beef?

(b) that between 2 and 6 (inclusive) of the next 20 customers order fish?

(c) that of the next 10 customers, at most 1 of the first 5 orders chicken, and at least 2 of the last 5 orders

beef.

(d) that of the next 5 customers, the first orders chicken, the second orders fish, and of the remaining 3, at

least 2 order beef?

Hint: For (c) and (d) remember that all customers choose their meal independently.

Problem Two

A manufacturer of rotors for drones claims that at most 3% of its rotors are defective.

(a) A random sample of 24 rotors is selected and it is found that 2 of them are defective. Is it fair to reject the

manufacturer's claim based on this observation?

(b) A random sample of 24 rotors is selected and it is found that 4 of them are defective. Now is it fair to

reject the manufacturer's claim based on this observation?

Hint: Be careful, this is NOT a question about the probably of exactly 2 or exactly 4 being defective. The

manufacturer is claiming at most 3%, meaning more than 3% is not possible. So you want to consider, for K

defective rotors, the probability P(X ≥ K). What is really being asked is the following. Suppose X = "the

number of defective rotors in a shipment of N rotors, with the assumption that the probability of any

individual rotor being defective is at most 0.03." Is this binomial distribution a reasonable model for the

company's quality control efforts? When K rotors are found to be defective, what we are really asking is: "is

this level of defective rotors, or worse, consistent with the model proposed by the company, where they said

it is at most 3%"? So we are interested in the probability of P(X ≥ K). If this probability is very small, then

something very, very unusual just happened when we tested the company's shipment, and we probably

want to reject the claim. If the probability is not small, then the model may be reasonable. This paradigm is

called "hypothesis testing" and it is essentially a probabalistic version of "proof by contradiction" (assume

the claim is true, and then derive a contradiction, proving that the claim is false; here we prove that if the

assumption leads to a conclusion with a very small probability, then the original assumption was probably

not true).

2018/10/9 hw05

http://localhost:8888/nbconvert/html/CS237/hw05.ipynb?download=false 4/5

Problem Three

Suppose that in West Campus in April of 2018, out of 12 accidents that resulted in trips to Health Services or

the emergency room, 4 happened on Friday the 13th. Is this a good reason for my GF Liz, who is very

superstitious, to worry that next Friday, September the 13th, 2019, I am particularly in danger in my dorm

room in Rich Hall? Since you are comparing April and September, you only have to worry about months with

30 days.

Hint: This is similar to the last one, but the model in question is that we know that 12 accidents occurred in

April of 2018, and the probability that any one of them occured on Friday the 13th is the same as any other

day, namely 1/30. Therefore the binomial model is X = "how many of the 12 accidents occurred on Friday the

13th?" You want to consider the likelihood of at least 4 accidents on that date.

Problem Four

Consider the simple error-detection scheme of parity checking, in which the sender appends to each 7-bit

"message" an 8th bit to make the total number of 1's in the 8 bits an even number. The receiver checks the

number of 1's in the 8-bit message and signals an error if this is an odd number. This works well for an odd

number of errors, but fails to detect an even number of errors. (Google this if you are unclear about the

algorithm.) Suppose that each bit is received correctly with probability 0.999, independently of the other bits.

What is the probability that the receiver signals that a message has an error, but the error is NOT detected by

the parity check?

Problem Five

Suppose that each day the price of a stock moves up 1/8th of a point with probability 1/3 and moves down

1/8th of the point with probability 2/3. If the price fluctuations from day to day are independent and

identically distributed, what is the probability that after 6 days the stock has its original price?

Hint: you could draw a tree, but it is easier to answer the following question: how many moves up and how

many moves down result in no change in the stock price after 3 days?

Problem Six

The probability that a child of a certain couple inherits a certain non-deadly disease is 0.23 independently of

their other children inheriting the disease.

(a) Suppose the couple decides, before having children, that they can tolerate at most a probability of 0.25 of

having the disease in any of their children. What is the maximum number of children they can have and keep

the probability of no disease among their children larger than 0.25? For simplicity, assume they decide

before having any child how many they should have.

(b) If the family has 5 children and the disease is detected in one child, what is the probability that exactly 2

more children have the disease as well?

Hint: for (a) just try various numbers of children; (b) is a conditional probability.

2018/10/9 hw05

http://localhost:8888/nbconvert/html/CS237/hw05.ipynb?download=false 5/5

Problem Seven

(a) If you roll a die 5 times, what is the probability of 5 or 6 showing on the die in exactly 2 of the rolls?

(b) If two fair dice are rolled 10 times, what is the probability of at least one 6 (on either die) in exactly five of

these 10 rolls?

Problem Eight

Suppose a professor of probability is tired of reading the depressing news and so he decides that he will

quickly scan the first 5 headlines in the New Yorks Times and the first 5 headlines in the Boston Globe and if

at most 3 of the articles in each are depressing, he will read the news that day. Further suppose that the

probability of a NYTs headline being depressing is 0.6 and for the Globe the probability of a headline being

depressing is 0.55.

(a) What is the probability that he will read the news the first day he tries this?

(b) In order to be "well-informed" he needs to read the news at least half the time; what is the probability that

he will be well-informed after doing this for a week?

Hint: This is another problem where there are two independent parts of the random experiment. You might

want to phrase it as three different random variables, all three binomial.

Problem Nine

Suppose numbers in the range are randomly and independently selected and rounded to 3 decimal

places. Therefore we can assume that all possible combinations of 3 digits after the decimal point are

equally likely.

(a) What is the probability that the first selection is no more than 0.345?

(b) What is the probability that 0.345 occurs at least twice in the first 1000 selections?

(c) What is the probability that 0.345 is selected for the first time on the 1000th selection?

Hint: This problem uses both of the distributions we studied on Thursday 10/4; (c) uses the Geometric, but

you should be able to figure it out easily by translating it into a question about coins!

Problem Ten

Suppose that jury members decide on each case independently, and each makes the correct decision

randomly with probability p. If the decision of the majority is final, which is preferable in arriving at correct

verdicts, a 3-person jury or a single juror?

Hint: This will depend on p. For p ∈ {0, 1/2, 1 }, it will make no difference. For other cases it will make a

difference. Explain carefully how this plays out depending on p and show all the calculations. You need to

calculate the probability of a successful decision with a 3-person jury, and compare that with the probability

of a correct decision with a single juror (which is just p). When the former is larger than the latter, then the 3-

person jury is preferable. That is, assuming you are innocent!


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp