Homework

8.4.3. Homework#

  • Use this assignment to practice the chapter’s concepts and coding skills in runnable Python code.

  • Sign in from the account menu before you start working on the assignment.

  • Write and run your code directly in the coding cells.

  • Multiple submissions are allowed. The highest score is kept.

1. A Valid Model?

A shipping team writes down this model for one delivery: on time with probability 0.80, 1 day late with probability 0.15, and 3 or more days late with probability 0.10. This is a valid probability model.

2. Reading an Expected Value

The expected late-delivery credit is $1.75 per shipment. This means a typical shipment costs the store $1.75 in credits.

3. Mean vs Median

A company pays most employees between $50,000 and $80,000, but a few executives earn over $1 million. The median salary describes a typical employee better than the mean salary does.

4. Two Surveys

A random sample of 100 customers shows 72% are satisfied. A second random sample of 100 customers, taken the same week, shows 68%. The difference shows that customer satisfaction changed.

5. Bigger Samples

If a manager surveys 400 customers instead of 100, the standard error of the sample proportion is cut in half.

### 6. Return Rate
# Each row of orders is one order. Use the data to estimate probabilities.
#   1. Compute the proportion of orders that were returned.
#   2. Use the complement to compute the proportion that were kept.
# Print exactly:
# Return rate: 0.15
# Kept rate: 0.85
import numpy as np
import pandas as pd

orders = pd.DataFrame({
    "returned": ["No", "No", "Yes", "No", "No", "No", "No", "No", "Yes", "No",
                 "No", "No", "No", "No", "No", "Yes", "No", "No", "No", "No"],
})

### Your code starts here.



### Your code ends here.
### 7. Items per Order
# The warehouse recorded how many items were in each of 10 orders.
#   1. Use value_counts(normalize=True) to get the empirical distribution of items.
#   2. Print the proportion of orders with exactly 2 items.
#   3. Print the average number of items per order.
# Print exactly:
# Proportion with 2 items: 0.4
# Average items: 2.1
import numpy as np
import pandas as pd

items = pd.Series([1, 2, 2, 3, 1, 2, 4, 2, 1, 3])

### Your code starts here.



### Your code ends here.
### 8. Call Wait Times
# A call center recorded wait times in minutes.
#   1. Compute the median wait time.
#   2. Compute the 90th percentile of wait times with np.percentile().
# Print exactly:
# Median wait: 4.5
# 90th percentile: 12.1
import numpy as np
import pandas as pd

waits = pd.Series([2, 3, 3, 4, 4, 5, 6, 7, 12, 13])

### Your code starts here.



### Your code ends here.
### 9. One Large Order
# Daily revenue for a week, including one unusually large corporate order.
#   1. Compute the mean and median of revenue.
#   2. Drop the largest value and compute the mean and median again.
#   3. Which statistic changed more?
# Print exactly:
# Mean with large order: 1100.0
# Mean without: 600.0
# Median with large order: 600.0
# Median without: 600.0
import numpy as np
import pandas as pd

revenue = pd.Series([500, 650, 600, 550, 700, 600, 4100])

### Your code starts here.



### Your code ends here.
### 10. Precision of an Average
# Order values have a standard deviation of $12. The standard error of a sample
# mean is sd / sqrt(n).
#   1. Compute the standard error of the mean order value for n = 36 orders.
#   2. Find the sample size that cuts that standard error in half, and compute its SE.
# Print exactly:
# SE with n=36: 2.0
# SE with n=144: 1.0
import numpy as np
import pandas as pd

sd = 12

### Your code starts here.



### Your code ends here.