---
title: "Test 1 Practice Questions (Solutions)"
subtitle: "Introductory Statistics"
author: "Resource made by Prof. Vinay Kodipelly for MATH 1320"
date: last-modified
format:
  html:
    toc: true
    toc-location: left
    theme: cosmo
    code-tools: true      # adds copy button for code
    code-fold: false      # always show code (beginner-friendly)
    code-overflow: wrap   # wrap long lines
    anchor-sections: true
    df-print: paged
    number-sections: true
    embed-resources: true
editor: visual
---

## Instructions

> **How to use this template (for non-coders):** 1) Type your **Final Answer** in one sentence.\
> 2) Show your **Work** clearly (definitions → formula → numbers → result).\
> 3) If calculations are needed, paste the **R Code** into the chunk and run it. Keep code short and commented.
>
> **Tip:** Keep units and interpretation in your Final Answer. Use the **Copy** button on code blocks if you need to reuse code.

### Important Note for Students
> **This document is a one-time resource for Test 1.**
>
> 1.  **Future Tests:** I will **not** provide a similar template for Test 2 or Test 3. By then, you should be relying on your own personalized RStudio notes.
> 2.  **RStudio is a Calculator:** Treat this Quarto document like a calculator. Just as a TI-84 has specific commands you learn over time, RStudio has commands. Attempting to memorize everything at once is overwhelming—be patient and adapt as you go.
> 3.  **Practice:** Many questions here mirror the MyLabMath non-graded Test 1 review. You are welcome to use this document during the open-book test.

```{r}
#| label: setup
#| include: false
# Beginner-friendly defaults for all chunks in this document.
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE,
                      fig.align = "center", fig.width = 7, fig.height = 4)
```

### Question Template (Copy-Paste)

Copy this under any question and fill in each part.

```` markdown
#### Final Answer
(Type one sentence with units and a short interpretation.)

#### Work (Show Your Steps)
- Define symbols & knowns
- Write the formula you will use
- Substitute numbers and compute
- Interpret the result in context

#### R Code (if needed)
```{r}
# Minimal example:
# dbinom(x, size = n, prob = p)       # Binomial: Exactly
# pbinom(x, size = n, prob = p)       # Binomial: At most
# 1 - pbinom(x-1, size=n, prob=p)     # Binomial: At least
# dpois(x, lambda)                    # Poisson: Exactly
# ppois(x, lambda)                    # Poisson: At most
# 1 - ppois(x-1, lambda)              # Poisson: At least
```
````

### **Example of a Meticulous Answer (Conceptual Question)**

## Question 1

Classify the study as either descriptive or inferential. Explain your answer. The table below shows data on average professional athletes' salaries for the years 2005 and 2011.

| Sport | Average salary ($millions) 2005 | Average salary ($millions) 2011 |   |
|------------------------|------------------------|------------------------|
| Baseball (MLB) | 2.48 | 3.31 |
| Basketball (NBA) | 5.15 | 4.04 |
| Football (NFL) | 1.90 | 1.40 |

------------------------------------------------------------------------

#### **Answer to Question 1**

**A. Final Answer:** The study is **descriptive**.

**B. Justification:** The study is classified as descriptive because its objective is to summarize the data that has been collected. The table provides a summary of the average salaries for athletes in three specific sports (MLB, NBA, NFL) for two specific years (2005 and 2011). It simply *describes* the situation for the data on hand. It does not attempt to use this data to make a prediction, draw a conclusion about a larger population (e.g., all professional athletes in the world), or test a hypothesis.

**C. Key Concepts:** \* **Descriptive Statistics:** Involves organizing, summarizing, and displaying data. The focus is on describing the main features of a collection of data (e.g., calculating the mean, median, creating charts). \* **Inferential Statistics:** Involves using data from a sample to make generalizations, predictions, or decisions about a larger population. This often involves probability and hypothesis testing.

------------------------------------------------------------------------

## Question 2

A recent article postulated that support for a certain scientist's theories increases with level of education. The table shown provides percentages of a certain country's adults, by educational level, who believe that evolution is a scientific theory well supported by evidence.

| Education              | Percentage |
|------------------------|------------|
| Postgraduate education | 65%        |
| College graduate       | 52%        |
| Some college education | 32%        |
| High school or less    | 20%        |

**a. Do you think that this study is descriptive or inferential? Explain your answer.**

**b. If, in fact, the study is inferential, identify the sample and population.**

------------------------------------------------------------------------

#### **Answer to Question 2**

#### Final Answer

a.  The study is **inferential** because it makes a general claim about the relationship between education and belief based on sample data.
b.  The **sample** is the group of adults surveyed, while the **population** is all adults in the country.

#### Work (Show Your Steps)

-   **a. Explanation:** The study is inferential. The key is the phrase "postulated that support... increases with level of education." This is a conclusion or generalization about a broad group (the population). The percentages are used as evidence from a smaller group (the sample) to support this broader claim. It's going beyond just describing the data collected.
-   **b. Sample vs. Population:**
    -   **Population:** The entire group of interest. In this case, it is "a certain country's adults."
    -   **Sample:** A subset of the population from which data is actually collected. Here, it's the specific individuals who were surveyed to generate the percentages in the table.

#### Personal Note

Think of it this way: "Descriptive" is like taking a photo—it shows exactly what was there at that moment. "Inferential" is like using that photo to predict what the entire scene (that you didn't capture) looks like. The claim about *all* adults makes it inferential.

------------------------------------------------------------------------

## Question 3

A simple qualitative data set has been provided. Complete parts (a) through (d) for this data set.

**Data Set:** `A, B, C, D, E, C, D, B, D, C`

------------------------------------------------------------------------

#### **Answer to Question 3**

#### Final Answer

The data set contains 10 observations with categories C and D being the most frequent (each appearing 3 times), and category A and E being the least frequent (each appearing once).

#### Work (Show Your Steps)

-   **(a) Frequency Distribution:** Count how many times each category appears.
    -   A: 1
    -   B: 2
    -   C: 3
    -   D: 3
    -   E: 1
    -   **Total:** 10
-   **(b) Relative-Frequency Distribution:** Divide each frequency by the total number of observations (10).
    -   A: 1/10 = 0.1
    -   B: 2/10 = 0.2
    -   C: 3/10 = 0.3
    -   D: 3/10 = 0.3
    -   E: 1/10 = 0.1
-   **(c) Bar Chart:** A chart with bars representing the frequency of each category.
-   **(d) Pie Chart:** A circular chart divided into slices to show the proportion of each category.

#### R Code (if needed)

```{r}
# Create the dataset
my_data <- c("A", "B", "C", "D", "E", "C", "D", "B", "D", "C")

# (a) Frequency Distribution
freq_table <- table(my_data)
freq_table

# (b) Relative-Frequency Distribution
rel_freq_table <- prop.table(freq_table)
rel_freq_table

# (c) Bar Chart
barplot(freq_table, main="Bar Chart of Frequencies", xlab="Category", ylab="Frequency")

# (d) Pie Chart
pie(freq_table, main="Pie Chart of Frequencies")
```

------------------------------------------------------------------------

## Question 4

A simple qualitative data set has been provided. Use this data set to complete parts (a) through (d) below.

**Data Set:** `A, D, A, E, C, A, D, B, A, E, E, D, C, B, B, A, B, A, E, D`

------------------------------------------------------------------------

#### **Answer to Question 4**

#### Final Answer

For the 20 observations provided, category 'A' is the mode, appearing 6 times (30% of the data).

#### Work (Show Your Steps)

-   **(a) Frequency Distribution:** Count the occurrences of each letter.
    -   A: 6
    -   B: 4
    -   C: 2
    -   D: 4
    -   E: 4
    -   **Total:** 20
-   **(b) Relative-Frequency Distribution:** Divide each frequency by the total (20).
    -   A: 6/20 = 0.30
    -   B: 4/20 = 0.20
    -   C: 2/20 = 0.10
    -   D: 4/20 = 0.20
    -   E: 4/20 = 0.20
-   **(c) Bar Chart & (d) Pie Chart:** These are visual representations of the tables above.

#### R Code (if needed)

```{r}
# Create the dataset
data_q4 <- c("A", "D", "A", "E", "C", "A", "D", "B", "A", "E", "E", "D", "C", "B", "B", "A", "B", "A", "E", "D")

# (a) Frequency table
freq_table_4 <- table(data_q4)
freq_table_4

# (b) Relative frequency table
rel_freq_table_4 <- prop.table(freq_table_4)
rel_freq_table_4

# (c) Bar Chart
barplot(freq_table_4, main="Bar Chart", xlab="Category", ylab="Frequency", col="lightblue")

# (d) Pie Chart
pie(freq_table_4, main="Pie Chart")
```

------------------------------------------------------------------------

## Question 5

The accompanying table lists the types of drug sold from a sample of convicted drug dealers. Use these data to complete parts (a) through (c).

| Drug  | Frequency |
|-------|-----------|
| A     | 73        |
| B     | 58        |
| C     | 40        |
| D     | 15        |
| E     | 19        |
| F     | 7         |
| Other | 3         |

------------------------------------------------------------------------

#### **Answer to Question 5**

#### Final Answer

Based on the sample of 215 convicted dealers, Drug A is the most common type sold, representing approximately 34% of cases.

#### Work (Show Your Steps)

-   **(a) Total Sample Size (n):** Sum the frequencies.
    -   n = 73 + 58 + 40 + 15 + 19 + 7 + 3 = 215
-   **(b) Relative-Frequency Distribution:** Divide each frequency by the total (215).
    -   A: 73/215 ≈ 0.340
    -   B: 58/215 ≈ 0.270
    -   C: 40/215 ≈ 0.186
    -   D: 15/215 ≈ 0.070
    -   E: 19/215 ≈ 0.088
    -   F: 7/215 ≈ 0.033
    -   Other: 3/215 ≈ 0.014
-   **(c) Bar Chart and Pie Chart:** Visuals based on the frequencies.

#### R Code (if needed)

```{r}
# Create the frequency vector and names
freq_q5 <- c(73, 58, 40, 15, 19, 7, 3)
names(freq_q5) <- c("A", "B", "C", "D", "E", "F", "Other")

# (a) Total sample size
total_n <- sum(freq_q5)
total_n

# (b) Relative frequencies
rel_freq_q5 <- prop.table(freq_q5)
rel_freq_q5

# (c) Bar Chart
barplot(freq_q5, main="Drug Types Sold", ylab="Frequency", col="salmon")

# (c) Pie Chart
pie(freq_q5, main="Proportion of Drug Types Sold")
```

------------------------------------------------------------------------

### **Example of a Meticulous Answer (Computational Question)**

## Question 6

The following table gives the number of tornadoes that touched down in the United States during each month of one year. Complete parts (a) through (c) below.

**Data Set:** `2, 3, 45, 117, 207, 91, 66, 86, 63, 54, 95, 97`

------------------------------------------------------------------------

#### **Answer to Question 6**

**A. Final Answers:** \* **Mean:** 77.2 tornadoes \* **Median:** 76.0 tornadoes \* **Mode:** There is no mode.

**B. R Code:**

```{r}
# Create the dataset for tornadoes
tornadoes <- c(2, 3, 45, 117, 207, 91, 66, 86, 63, 54, 95, 97)

# Calculate the mean
mean(tornadoes)

# Calculate the median
median(tornadoes)

# To find the mode, we can look at a frequency table
# Since all values are unique, there is no mode.
table(tornadoes)
```

**C. Detailed Solution:** 1. **Mean:** The mean is the sum of all values divided by the number of values. \* Sum = 2+3+45+117+207+91+66+86+63+54+95+97 = 926 \* Number of values = 12 \* Mean = 926 / 12 = 77.166... ≈ 77.2 2. **Median:** The median is the middle value of an ordered dataset. \* Ordered Data: `2, 3, 45, 54, 63, 66, 86, 91, 95, 97, 117, 207` \* Since there is an even number of values (12), the median is the average of the two middle values (the 6th and 7th). \* Median = (66 + 86) / 2 = 152 / 2 = 76.0 3. **Mode:** The mode is the value that appears most frequently. \* In this dataset, every value appears only once. Therefore, there is no mode.

**D. Interpretation:** \* The **mean** of 77.2 indicates that, on average, there were about 77 tornadoes per month during that year. \* The **median** of 76 tells us that half of the months had fewer than 76 tornadoes, and half had more. The mean is slightly higher than the median, which suggests the distribution might be slightly skewed to the right by the high value of 207. \* The lack of a **mode** signifies that no single number of tornadoes occurred more frequently than any other in a given month.

------------------------------------------------------------------------

## Question 7

The following table shows the wealth of 8 of the top 10 richest Americans as of September 19, 2012. Complete parts (a) through (c) below.

| Person                    | Wealth (\$ billions) |
|---------------------------|----------------------|
| Bill Gates                | 66.0                 |
| Warren Buffett            | 46.0                 |
| Charles Koch              | 31.0                 |
| David Koch                | 31.0                 |
| Christy Walton and family | 27.9                 |
| Alice Walton              | 26.3                 |
| Michael Bloomberg         | 25.0                 |
| S. Robson Walton          | 26.1                 |

------------------------------------------------------------------------

#### **Answer to Question 7**

#### Final Answer

The mean wealth is \$34.91 billion, the median is \$29.45 billion, and the mode is \$31.0 billion.

#### Work (Show Your Steps)

-   **Data:** 66.0, 46.0, 31.0, 31.0, 27.9, 26.3, 25.0, 26.1
-   **(a) Mean:** (66.0 + 46.0 + 31.0 + 31.0 + 27.9 + 26.3 + 25.0 + 26.1) / 8 = 279.3 / 8 ≈ 34.91
-   **(b) Median:** First, order the data: 25.0, 26.1, 26.3, 27.9, 31.0, 31.0, 46.0, 66.0. Since n=8 (even), the median is the average of the 4th and 5th values: (27.9 + 31.0) / 2 = 29.45
-   **(c) Mode:** The value that appears most often is 31.0.

#### R Code (if needed)

```{r}
# Create the wealth dataset
wealth <- c(66.0, 46.0, 31.0, 31.0, 27.9, 26.3, 25.0, 26.1)

# (a) Calculate the mean
mean(wealth)

# (b) Calculate the median
median(wealth)

# (c) Find the mode by creating a frequency table
table(wealth) # 31.0 appears twice, more than any other value.
```

------------------------------------------------------------------------

## Question 8

Consider the data set: `3, 4, 5, 6, 7, 8, 9, 10, 11`. Complete parts (a) through (c) below. a. Use the defining formula to obtain the sample standard deviation. b. Replace the 11 in the data set by 111 and again use the defining formula to compute the sample standard deviation. c. Compare your answers in parts (a) and (b). The lack of what property of the standard deviation accounts for its extreme sensitivity to the change of 11 to 111?

------------------------------------------------------------------------

#### **Answer to Question 8**

#### Final Answer

a.  The original sample standard deviation is approximately 2.739.
b.  After replacing 11 with 111, the sample standard deviation increases dramatically to approximately 35.53.
c.  The standard deviation is not **resistant** to outliers, which explains its sensitivity.

#### Work (Show Your Steps)

-   **Formula:** Sample standard deviation, $s = \sqrt{\frac{\sum(x_i - \bar{x})^2}{n-1}}$
-   **(a) Original Data:**
    -   n = 9
    -   Mean ($\bar{x}$) = (3+4+5+6+7+8+9+10+11) / 9 = 63 / 9 = 7
    -   Sum of squared differences: $(3-7)^2 + (4-7)^2 + ... + (11-7)^2 = 16+9+4+1+0+1+4+9+16 = 60$
    -   $s = \sqrt{60 / (9-1)} = \sqrt{60 / 8} = \sqrt{7.5} \approx 2.739$
-   **(b) New Data (with 111):**
    -   n = 9
    -   New Mean ($\bar{x}$) = (3+4+5+6+7+8+9+10+111) / 9 = 163 / 9 ≈ 18.11
    -   Sum of squared differences: $(3-18.11)^2 + ... + (111-18.11)^2 \approx 10108.89$
    -   $s = \sqrt{10108.89 / 8} \approx \sqrt{1263.61} \approx 35.53$
-   **(c) Comparison:** The standard deviation increased more than tenfold due to a single outlier. This is because the standard deviation (and the mean it's based on) are not **resistant measures**. Resistant measures are not strongly affected by extreme values. The median and IQR are examples of resistant measures.

#### R Code (if needed)

```{r}
# (a) Original data
data_a <- c(3, 4, 5, 6, 7, 8, 9, 10, 11)
sd(data_a)

# (b) Data with outlier
data_b <- c(3, 4, 5, 6, 7, 8, 9, 10, 111)
sd(data_b)
```

------------------------------------------------------------------------

## Question 9

A simple data set has been provided to practice the basics of finding measures of variation. For the data set, determine the: a. range. b. sample standard deviation.

## **Data Set:** `1, 2, 3, 3`

#### **Answer to Question 9**

#### Final Answer

The range of the data is 2, and the sample standard deviation is approximately 0.957.

#### Work (Show Your Steps)

-   **(a) Range:** Max value - Min value = 3 - 1 = 2
-   **(b) Sample Standard Deviation:**
    -   n = 4
    -   Mean ($\bar{x}$) = (1+2+3+3) / 4 = 9 / 4 = 2.25
    -   Sum of squared differences: $(1-2.25)^2 + (2-2.25)^2 + (3-2.25)^2 + (3-2.25)^2 = 1.5625 + 0.0625 + 0.5625 + 0.5625 = 2.75$
    -   $s = \sqrt{2.75 / (4-1)} = \sqrt{2.75 / 3} \approx 0.957$

#### R Code (if needed)

```{r}
data_q9 <- c(1, 2, 3, 3)

# (a) Range
range_val <- max(data_q9) - min(data_q9)
range_val
# Alternatively:
range(data_q9) # This gives min and max, not the difference

# (b) Sample standard deviation
sd(data_q9)
```

------------------------------------------------------------------------

## Question 10

A simple data set has been provided to practice the basics of finding measures of variation. For the data set, determine the: a. range. b. sample standard deviation.

## **Data Set:** `9, 1, 8, 4, 7`

#### **Answer to Question 10**

#### Final Answer

The range is 8 and the sample standard deviation is approximately 3.36.

#### Work (Show Your Steps)

-   **(a) Range:** Max - Min = 9 - 1 = 8
-   **(b) Sample Standard Deviation:**
    -   n = 5
    -   Mean ($\bar{x}$) = (9+1+8+4+7) / 5 = 29 / 5 = 5.8
    -   Sum of squared diffs: $(9-5.8)^2 + (1-5.8)^2 + (8-5.8)^2 + (4-5.8)^2 + (7-5.8)^2 = 10.24 + 23.04 + 4.84 + 3.24 + 1.44 = 42.8$
    -   $s = \sqrt{42.8 / (5-1)} = \sqrt{10.7} \approx 3.27$

#### R Code (if needed)

```{r}
data_q10 <- c(9, 1, 8, 4, 7)
# (a) Range
max(data_q10) - min(data_q10)
# (b) Sample standard deviation
sd(data_q10)
```

------------------------------------------------------------------------

## Question 11

Provided below is a simple data set for you to practice finding descriptive measures. For the data set, complete parts (a) through (c).

**Data Set:** `2, 4, 6, 8, 9, 2, 4, 6, 8, 9`

a.  Obtain the quartiles.
b.  Determine the interquartile range.
c.  Find the five-number summary.

------------------------------------------------------------------------

#### **Answer to Question 11**

**A. Final Answers:** \* Quartiles (Q1, Median/Q2, Q3): **4, 6, 8** \* Interquartile Range (IQR): **4** \* Five-number summary (Min, Q1, Median, Q3, Max): **(2, 4, 6, 8, 9)**

**B. Work (Show Your Steps):** \* First, sort the data: `2, 2, 4, 4, 6, 6, 8, 8, 9, 9`. There are n=10 values. \* **Median (Q2):** Average of the 5th and 6th values → (6 + 6)/2 = 6. \* **Q1:** Median of the lower half (`2, 2, 4, 4, 6`). The middle value is the 3rd one, which is **4**. \* **Q3:** Median of the upper half (`6, 8, 8, 9, 9`). The middle value is the 3rd one, which is **8**. \* **IQR:** Q3 − Q1 = 8 − 4 = **4**. \* **Five-number summary:** Minimum (2), Q1 (4), Median (6), Q3 (8), Maximum (9).

**C. R Code (simple):**

```{r}
x <- c(2,4,6,8,9,2,4,6,8,9)
sort(x)
# a. Quartiles
quantile(x, probs = c(0.25, 0.5, 0.75))
# b. IQR
IQR(x)
# c. Five-number summary
summary(x)
# or fivenum()
fivenum(x)
```

------------------------------------------------------------------------

## Question 12

Provided below is a simple data set for you to practice finding descriptive measures. For the data set, complete parts (a) through (c) below.

**Data Set:** `1, 3, 5, 6, 7, 8, 1, 3, 5, 6, 7, 8`

a.  Obtain the quartiles.
b.  Determine the interquartile range.
c.  Find the five-number summary.

------------------------------------------------------------------------

#### **Answer to Question 12**

#### Final Answer

The quartiles are Q1=3, Median=5.5, Q3=7; the IQR is 4; and the five-number summary is (1, 3, 5.5, 7, 8).

#### Work (Show Your Steps)

-   **Sorted Data:** `1, 1, 3, 3, 5, 5, 6, 6, 7, 7, 8, 8` (n=12)
-   **(a) Quartiles:**
    -   Median (Q2): Average of 6th and 7th values -\> (5 + 6)/2 = 5.5
    -   Q1: Median of lower half (`1, 1, 3, 3, 5, 5`) -\> (3 + 3)/2 = 3
    -   Q3: Median of upper half (`6, 6, 7, 7, 8, 8`) -\> (7 + 7)/2 = 7
-   **(b) IQR:** Q3 - Q1 = 7 - 3 = 4
-   **(c) Five-Number Summary:** Min(1), Q1(3), Median(5.5), Q3(7), Max(8)

#### R Code (if needed)

```{r}
data_q12 <- c(1, 3, 5, 6, 7, 8, 1, 3, 5, 6, 7, 8)
# (a) Quartiles
quantile(data_q12)
# (b) IQR
IQR(data_q12)
# (c) Five-number summary
summary(data_q12)
```

------------------------------------------------------------------------

## Question 13

A statistic center compiles data on the length of stay by patients in short-term hospitals. A random sample of 21 patients yielded the data on length of stay, in days, shown below. Complete parts (a) through (e) below.

**Data Set:** `25, 3, 5, 19, 5, 17, 55, 23, 23, 21, 13, 5, 21, 2, 22, 23, 5, 20, 21, 15, 23`

a.  Obtain and interpret the quartiles.
b.  Determine and interpret the interquartile range (IQR).
c.  Find and interpret the five-number summary.
d.  Identify potential outliers, if any.
e.  Construct and interpret a boxplot.

------------------------------------------------------------------------

#### **Answer to Question 13**

#### Final Answer

The five-number summary for patient stay is (2, 5, 21, 23, 55) days. The value 55 is a potential outlier, indicating an unusually long hospital stay compared to the rest of the sample.

#### Work (Show Your Steps)

-   **Sorted Data (n=21):** `2, 3, 5, 5, 5, 5, 13, 15, 17, 19, 20, 21, 21, 21, 22, 23, 23, 23, 23, 25, 55`
-   **(a) Quartiles:**
    -   Q1 (25th percentile): The 6th value is **5**. (25% of patients stay 5 days or less).
    -   Median (Q2, 50th percentile): The 11th value is **20**. (Half of patients stay 20 days or less).
    -   Q3 (75th percentile): The 16th value is **23**. (75% of patients stay 23 days or less).
-   **(b) IQR:** Q3 - Q1 = 23 - 5 = **18**. The middle 50% of patient stays span a range of 18 days.
-   **(c) Five-Number Summary:** Min(2), Q1(5), Median(20), Q3(23), Max(55). This summarizes the distribution of hospital stays.
-   **(d) Outliers:**
    -   Lower Fence: Q1 - 1.5 \* IQR = 5 - 1.5 \* 18 = 5 - 27 = -22.
    -   Upper Fence: Q3 + 1.5 \* IQR = 23 + 1.5 \* 18 = 23 + 27 = 50.
    -   Any value below -22 or above 50 is a potential outlier. The value **55** is above the upper fence, so it is a potential outlier.
-   **(e) Boxplot:** The boxplot will show the box from 5 to 23, a line at 20, whiskers extending to the min (2) and the last non-outlier value (25), and a separate point for the outlier at 55. This visually confirms the data is right-skewed with one high outlier.

#### R Code (if needed)

```{r}
data_q13 <- c(25, 3, 5, 19, 5, 17, 55, 23, 23, 21, 13, 5, 21, 2, 22, 23, 5, 20, 21, 15, 23)

# a, b, c - Use summary()
summary(data_q13)

# d - Calculate fences to find outliers
Q1 <- quantile(data_q13, 0.25)
Q3 <- quantile(data_q13, 0.75)
IQR_val <- IQR(data_q13)
lower_fence <- Q1 - 1.5 * IQR_val
upper_fence <- Q3 + 1.5 * IQR_val
lower_fence
upper_fence

# Outliers (if any):
data_q13[data_q13 < lower_fence | data_q13 > upper_fence]


# e - Boxplot
boxplot(data_q13, horizontal=TRUE, main="Boxplot of Patient Stays (days)", xlab="Days")
```

------------------------------------------------------------------------

## Question 14

An ordinary deck of playing cards has 52 cards. There are four suits—spades, hearts, diamonds, and clubs—with 13 cards in each suit. Spades and clubs are black; hearts and diamonds are red. If one of these cards is selected at random, what is the probability that it is: a. a club? b. red? c. not a heart? ------------------------------------------------------------------------

#### **Answer to Question 14**

#### Final Answer

The probabilities are: a) 1/4 or 0.25 for a club, b) 1/2 or 0.5 for a red card, and c) 3/4 or 0.75 for not a heart.

#### Work (Show Your Steps)

-   **Total Outcomes:** 52 cards.
-   **(a) P(club):** There are 13 clubs. P(club) = 13 / 52 = 1/4.
-   **(b) P(red):** There are 13 hearts + 13 diamonds = 26 red cards. P(red) = 26 / 52 = 1/2.
-   **(c) P(not a heart):** There are 13 hearts. The number of cards that are not hearts is 52 - 13 = 39. P(not a heart) = 39 / 52 = 3/4.
    -   **Alternatively (using complement rule):** P(not heart) = 1 - P(heart) = 1 - (13/52) = 1 - 1/4 = 3/4.

#### R Code (if needed)

```{r}
# These are simple fractions, but R can do the arithmetic
# a. P(club)
13/52
# b. P(red)
26/52
# c. P(not a heart)
39/52
# or using the complement rule
1 - (13/52)
```

------------------------------------------------------------------------

## Question 15

A frequency distribution for an election in a certain country is given in the accompanying table. Complete parts (a) through (c) below.

| Candidate   | Votes      |
|-------------|------------|
| Candidate 1 | 43,042,982 |
| Candidate 2 | 13,127,154 |
| Candidate 3 | 8,162,539  |
| Candidate 4 | 3,971,803  |
| Candidate 5 | 2,978,489  |

a.  Find the probability that a randomly selected voter voted for Candidate 3.

b.  Find the probability that a randomly selected voter voted for either Candidate 1 or Candidate 4.

c.  

    ## Find the probability that a randomly selected voter voted for someone other than Candidate 3.

#### **Answer to Question 15**

#### Final Answer

The probabilities are: a) \~11.45% for Candidate 3, b) \~65.98% for Candidate 1 or 4, and c) \~88.55% for someone other than Candidate 3.

#### Work (Show Your Steps)

-   **Total Votes:** 43042982 + 13127154 + 8162539 + 3971803 + 2978489 = 71,282,967
-   **(a) P(Cand 3):** (Votes for 3) / (Total Votes) = 8,162,539 / 71,282,967 ≈ 0.1145
-   **(b) P(Cand 1 or Cand 4):** (Votes for 1 + Votes for 4) / Total = (43,042,982 + 3,971,803) / 71,282,967 = 47,014,785 / 71,282,967 ≈ 0.6595
-   **(c) P(not Cand 3):** 1 - P(Cand 3) = 1 - 0.1145 ≈ 0.8855

#### R Code (if needed)

```{r}
# Create vector of votes
votes <- c(43042982, 13127154, 8162539, 3971803, 2978489)
total_votes <- sum(votes)

# (a) P(Candidate 3) - it's the 3rd element
p_cand3 <- votes[3] / total_votes
p_cand3

# (b) P(Candidate 1 or 4)
p_cand1_or_4 <- (votes[1] + votes[4]) / total_votes
p_cand1_or_4

# (c) P(not Candidate 3)
p_not_cand3 <- 1 - p_cand3
p_not_cand3
```

------------------------------------------------------------------------

## Question 16 & 17

Construct a Venn diagram representing each event. 16a. (K & L) 16b. (K & L & T) 17a. (P & (not B)) 17b. ((P or B) & (not (P and B))) ------------------------------------------------------------------------

#### **Answer to Question 16 & 17**

#### Final Answer

These questions ask for descriptions of shaded regions in Venn diagrams. - 16a: The intersection (overlap) of circles K and L. - 16b: The common intersection (overlap) of all three circles K, L, and T. - 17a: The part of circle P that does *not* overlap with circle B. - 17b: The parts of circles P and B that are *not* in their common overlap (the union minus the intersection).

#### Work (Show Your Steps)

-   **16a. (K & L):** Draw two overlapping circles, one for K and one for L. Shade only the lens-shaped area where they overlap. This represents outcomes that are in both K AND L.
-   **16b. (K & L & T):** Draw three overlapping circles (K, L, T). Shade only the small central region where all three circles intersect. This is for outcomes in K AND L AND T.
-   **17a. (P & (not B)):** Draw two overlapping circles, P and B. Shade the part of circle P that is outside of circle B. This is the region for outcomes in P but NOT in B.
-   **17b. ((P or B) & (not (P and B))):** Draw two overlapping circles, P and B. The "(P or B)" part is everything inside both circles combined. The "(not (P and B))" part means we exclude the intersection. So, you shade everything in P and everything in B *except* for their shared overlap. This is also called the "symmetric difference."

------------------------------------------------------------------------

## Question 18

Find the probability P(E or F) if E and F are mutually exclusive, $P(E)=0.25,$ and $P(F)=0.47.$

------------------------------------------------------------------------

#### **Answer to Question 18**

**A. Final Answer:** Since E and F are mutually exclusive, **P(E or F) = P(E) + P(F) = 0.25 + 0.47 = 0.72**.

**B. Personal Note:** "Mutually exclusive" is a key phrase. It means the events E and F cannot happen at the same time, so their intersection P(E and F) is 0. This simplifies the general addition rule.

**C. R Code:**

```{r}
pe <- 0.25; pf <- 0.47
pe + pf
```

------------------------------------------------------------------------

## Question 19

Find the probability of the indicated event if $P(E)=0.30$ and $P(F)=0.55.$ Find P(E or F) if P(E and F) $=0.05$.

------------------------------------------------------------------------

#### **Answer to Question 19**

**A. Final Answer:** Using the General Addition Rule: **P(E or F) = P(E) + P(F) − P(E and F) = 0.30 + 0.55 − 0.05 = 0.80**.

**B. Personal Note:** Here, the events are *not* mutually exclusive because P(E and F) is not zero. We must subtract the overlap to avoid double-counting it.

**C. R Code:**

```{r}
pe <- 0.30; pf <- 0.55; pe_and_f <- 0.05
pe + pf - pe_and_f
```

------------------------------------------------------------------------

## Question 20

A recent census found that 51.8% of adults are female, 10.6% are divorced, and 5.7% are divorced females. For an adult selected at random, let F be the event that the person is female, and D be the event that the person is divorced.

a.  Obtain $P(F)$, $P(D)$, and P(F&D).

b.  Determine $P(F$ or D), and interpret your answer in terms of percentages.

c.  

    ## Find the probability that a randomly selected adult is male.

#### **Answer to Question 20**

#### Final Answer

a)  The probabilities are P(F)=0.518, P(D)=0.106, P(F&D)=0.057. b) The probability of being female or divorced is 0.567, meaning 56.7% of adults are female or divorced. c) The probability of being male is 0.482.

#### Work (Show Your Steps)

-   **(a) Given Probabilities:**
    -   P(F) = 51.8% = 0.518
    -   P(D) = 10.6% = 0.106
    -   P(F & D) = 5.7% = 0.057
-   **(b) P(F or D):** Use the General Addition Rule.
    -   P(F or D) = P(F) + P(D) - P(F & D)
    -   P(F or D) = 0.518 + 0.106 - 0.057 = 0.567
    -   **Interpretation:** 56.7% of the adult population is either female or divorced (or both).
-   **(c) P(Male):** Male is the complement of female.
    -   P(Male) = 1 - P(F) = 1 - 0.518 = 0.482

#### R Code (if needed)

```{r}
pF <- 0.518
pD <- 0.106
pF_and_D <- 0.057

# b. P(F or D)
pF_or_D <- pF + pD - pF_and_D
print(pF_or_D)

# c. P(Male)
pMale <- 1 - pF
print(pMale)
```

------------------------------------------------------------------------

## Question 21

An incomplete contingency table is provided. Use this table to complete the following.

|       | $C_1$ | $C_2$ | Total |
|-------|:-----:|:-----:|:-----:|
| $R_1$ |   4   |       |  12   |
| $R_2$ |       |   6   |       |
| Total |       |       |  30   |

a.  Fill in the missing entries in the contingency table.

b.  Determine $P(C_{1})$, $P(R_{2})$, and $P(C_{1}$ & $R_{2}$).

c.  

    ## Construct the corresponding joint probability distribution.

#### **Answer to Question 21**

#### Final Answer

b)  The probabilities are P(C1) ≈ 0.533, P(R2) = 0.6, and P(C1 & R2) = 0.4.

#### Work (Show Your Steps)

-   **(a) Completed Table:**
    -   R1, C2 = 12 - 4 = 8
    -   Total R2 = 30 - 12 = 18
    -   R2, C1 = 18 - 6 = 12
    -   Total C1 = 4 + 12 = 16
    -   Total C2 = 8 + 6 = 14

|       | $C_1$ | $C_2$ | Total |
|-------|:-----:|:-----:|:-----:|
| $R_1$ |   4   |   8   |  12   |
| $R_2$ |  12   |   6   |  18   |
| Total |  16   |  14   |  30   |

-   **(b) Probabilities (from the margins and cells):**
    -   P(C1) = (Total for C1) / (Grand Total) = 16 / 30 ≈ 0.533
    -   P(R2) = (Total for R2) / (Grand Total) = 18 / 30 = 0.6
    -   P(C1 & R2) = (Cell for C1 and R2) / (Grand Total) = 12 / 30 = 0.4
-   **(c) Joint Probability Distribution (divide each cell by 30):** \| \| $C_1$ \| $C_2$ \| Total \| \|-------\|:----------:\|:----------:\|:-----:\| \| $R_1$ \| 4/30≈0.133 \| 8/30≈0.267 \| 0.400 \| \| $R_2$ \| 12/30=0.400\| 6/30=0.200 \| 0.600 \| \| Total \| 16/30≈0.533\| 14/30≈0.467\| 1.000 \|

#### R Code (if needed)

```{r}
# You can represent the table as a matrix in R
counts_table <- matrix(c(4, 12, 8, 6), nrow=2, byrow=TRUE)
# Add totals (margins)
addmargins(counts_table)

# Calculate probabilities
prob_table <- prop.table(counts_table)
addmargins(prob_table)

# b. Specific probabilities
P_C1 <- 16/30
P_R2 <- 18/30
P_C1_and_R2 <- 12/30
c(P_C1, P_R2, P_C1_and_R2)
```

------------------------------------------------------------------------

## Question 22

Suppose that C and D are two events such that $P(C)=\frac{4}{5}$ and $P(C\&D)=\frac{3}{5}.$ What is $P(D|C)?$

------------------------------------------------------------------------

#### **Answer to Question 22**

#### Final Answer

The conditional probability of D given C, P(D\|C), is 3/4 or 0.75.

#### Work (Show Your Steps)

-   **Formula:** The definition of conditional probability is $P(D|C) = \frac{P(C \& D)}{P(C)}$.
-   **Substitution:** We are given P(C & D) = 3/5 and P(C) = 4/5.
-   **Calculation:** $P(D|C) = \frac{3/5}{4/5} = \frac{3}{5} \times \frac{5}{4} = \frac{3}{4} = 0.75$.

#### R Code (if needed)

```{r}
p_c_and_d <- 3/5
p_c <- 4/5
p_d_given_c <- p_c_and_d / p_c
p_d_given_c
```

------------------------------------------------------------------------

## Question 23

A national military bureau for a certain country collects data on active members in the military. According to a national journal, 78.5% of military members are in the reserves and 11.6% of military members are Black and in the reserves. What percentage of military members in the reserves are Black?

------------------------------------------------------------------------

#### **Answer to Question 23**

#### Final Answer

Approximately 14.78% of military members who are in the reserves are Black.

#### Work (Show Your Steps)

-   **Define Events:**
    -   R = a member is in the reserves
    -   B = a member is Black
-   **Given Probabilities:**
    -   P(R) = 0.785
    -   P(B & R) = 0.116
-   **Goal:** Find the percentage of *reserves* that are Black. This is the conditional probability P(B \| R).
-   **Formula:** $P(B|R) = \frac{P(B \& R)}{P(R)}$
-   **Calculation:** $P(B|R) = \frac{0.116}{0.785} \approx 0.14777$ or 14.78%.

#### R Code (if needed)

```{r}
p_r <- 0.785
p_b_and_r <- 0.116
p_b_given_r <- p_b_and_r / p_r
p_b_given_r
```

------------------------------------------------------------------------

## Question 24

Suppose $P(A)=0.6$ and $P(B|A)=0.15.$ Find $P(A\&B)$.

------------------------------------------------------------------------

#### **Answer to Question 24**

#### Final Answer

The joint probability P(A & B) is 0.09.

#### Work (Show Your Steps)

-   **Formula:** The General Multiplication Rule is $P(A \& B) = P(A) \times P(B|A)$.
-   **Substitution:** We are given P(A) = 0.6 and P(B\|A) = 0.15.
-   **Calculation:** $P(A \& B) = 0.6 \times 0.15 = 0.09$.

#### R Code (if needed)

```{r}
p_a <- 0.6
p_b_given_a <- 0.15
p_a_and_b <- p_a * p_b_given_a
p_a_and_b
```

------------------------------------------------------------------------

## Question 25

Suppose that A and B are independent events such that $P(A)=0.5$ and $P(B)=0.3$. Find $P(A\&B)$.

------------------------------------------------------------------------

#### **Answer to Question 25**

#### Final Answer

Since the events are independent, P(A & B) is 0.15.

#### Work (Show Your Steps)

-   **Formula:** For independent events, the multiplication rule simplifies to $P(A \& B) = P(A) \times P(B)$.
-   **Substitution:** We have P(A) = 0.5 and P(B) = 0.3.
-   **Calculation:** $P(A \& B) = 0.5 \times 0.3 = 0.15$.

#### R Code (if needed)

```{r}
p_a <- 0.5
p_b <- 0.3
# For independent events
p_a_and_b <- p_a * p_b
p_a_and_b
```

------------------------------------------------------------------------

## Question 26

Decide whether or not the two events are independent or whether it is not possible to tell. Justify your answer. $P(D)=\frac{4}{9}$ and $P(D|C)=\frac{4}{9}$.

------------------------------------------------------------------------

#### **Answer to Question 26**

#### Final Answer

The events C and D are independent.

#### Work (Show Your Steps)

-   **Definition of Independence:** Two events C and D are independent if the occurrence of one does not affect the probability of the other. Mathematically, this means $P(D|C) = P(D)$.
-   **Justification:** We are given that $P(D|C) = 4/9$ and $P(D) = 4/9$. Since these two probabilities are equal, the fact that C has occurred does not change the probability of D. Therefore, by definition, the events are independent.

------------------------------------------------------------------------

## Question 27

Suppose that A, B, and C are independent events such that $P(A)=0.5,$ $P(B)=0.8,$ and $P(C)=0.7.$ Find P(A & B & C).

------------------------------------------------------------------------

#### **Answer to Question 27**

**A. Final Answer:** Since the events are independent, **P(A & B & C) = P(A) × P(B) × P(C) = 0.5 × 0.8 × 0.7 = 0.28**.

**B. R Code:**

```{r}
pa <- 0.5; pb <- 0.8; pc <- 0.7
pa * pb * pc
```

------------------------------------------------------------------------

## Question 28

Roughly 48% of men and 31% of women believe in extraterrestrial aliens. Of all adults, roughly 52% are men and 48% women. Complete parts (a) through (c) below.

a.  What percentage of adults believe in such aliens?
b.  What percentage of women believe in such aliens?
c.  What percentage of adults that believe in such aliens are women?

------------------------------------------------------------------------

#### **Answer to Question 28**

**A. Final Answers:** \* (a) The overall percentage of adults who believe in aliens is **39.84%**. \* (b) The percentage of women who believe in aliens is **31%** (this is given directly in the problem). \* (c) Among adults who believe in aliens, the percentage who are women is approximately **37.35%**.

**B. Work:** Let M=man, W=woman, B=believe. Given: P(M)=0.52, P(W)=0.48, P(B\|M)=0.48, P(B\|W)=0.31. \* **(a) P(B):** Use the Law of Total Probability. P(B) = P(B & M) + P(B & W) = P(M)P(B\|M) + P(W)P(B\|W) P(B) = (0.52)(0.48) + (0.48)(0.31) = 0.2496 + 0.1488 = 0.3984 → 39.84% \* **(c) P(W\|B):** Use Bayes' Theorem. P(W\|B) = P(W & B) / P(B) = \[P(W) \* P(B\|W)\] / P(B) P(W\|B) = (0.48 \* 0.31) / 0.3984 = 0.1488 / 0.3984 ≈ 0.3735 → 37.35%

**C. R Code:**

```{r}
pM <- 0.52; pW <- 0.48; pB_given_M <- 0.48; pB_given_W <- 0.31
# a. Overall P(B)
pB <- pM*pB_given_M + pW*pB_given_W
pB
# c. P(W|B)
pW_given_B <- (pW * pB_given_W) / pB
pW_given_B
```

------------------------------------------------------------------------

## Question 29

Find 0!, 4!, and 6!.

------------------------------------------------------------------------

#### **Answer to Question 29**

**A. Final Answers:** 0! = **1**; 4! = **24**; 6! = **720**

**B. Work:** \* 0! = 1 (by definition) \* 4! = 4 × 3 × 2 × 1 = 24 \* 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720

**C. R Code:**

```{r}
factorial(0)
factorial(4)
factorial(6)
```

------------------------------------------------------------------------

## Question 30

Determine the value of each quantity. a. ${}_{2}P_{1}$ b. ${}_{15}P_{7}$ c. ${}_{6}P_{4}$ d. ${}_{11}P_{0}$ e. ${}_{8}P_{8}$

------------------------------------------------------------------------

#### **Answer to Question 30**

**A. Final Answers (using formula nPr = n!/(n−r)!):** \* (a) ₂P₁ = **2** \* (b) ₁₅P₇ = **32,432,400** \* (c) ₆P₄ = **360** \* (d) ₁₁P₀ = **1** \* (e) ₈P₈ = **40,320**

**B. R Code:**

```{r}
# Permutation Formula: nPr = n! / (n-r)!
# calculate directly:
factorial(2) / factorial(1)
factorial(15) / factorial(8)
factorial(6) / factorial(2)
factorial(11) / factorial(11)
factorial(8) / factorial(0)
```

------------------------------------------------------------------------

## Question 31

From the official website of a major league baseball team, it is found that there were nine active players on roster available to play infield or be the catcher. Assuming that these nine players could play any infield position or catcher, how many possible assignments could the manager have made for the five infield positions and catcher?

------------------------------------------------------------------------

#### **Answer to Question 31**

#### Final Answer

There are 60,480 possible assignments for the six positions.

#### Work (Show Your Steps)

-   **Identify the problem type:** We are assigning players to specific, distinct positions (1B, 2B, 3B, SS, P, C). Since the order/position matters, this is a **permutation**.
-   **Define n and r:**
    -   n = total number of players to choose from = 9
    -   r = number of positions to fill = 5 infield + 1 catcher = 6
-   **Formula:** ${}_{n}P_{r} = \frac{n!}{(n-r)!}$
-   **Calculation:** ${}_{9}P_{6} = \frac{9!}{(9-6)!} = \frac{9!}{3!} = \frac{362,880}{6} = 60,480$.
    -   Or, think of it as 9 choices for the first position, 8 for the second, and so on: 9 × 8 × 7 × 6 × 5 × 4 = 60,480.

#### R Code (if needed)

```{r}
# 9P6 = 9! / (9-6)! = 9! / 3!
factorial(9) / factorial(3)

# Or directly: 9 * 8 * 7 * 6 * 5 * 4
9 * 8 * 7 * 6 * 5 * 4
```

------------------------------------------------------------------------

## Question 32

There are many choices to make when buying a new car. For a specific model of a new car, choices are available, among others, for roof (4), exterior color (13), seat fabric/color (7), interior trim (6), and wheels (6). How many possibilities are there altogether, taking into account choices for the five aforementioned items?

------------------------------------------------------------------------

#### **Answer to Question 32**

#### Final Answer

There are a total of 13,104 different possible car configurations.

#### Work (Show Your Steps)

-   **Identify the problem type:** The choice for each category is independent of the others. We can use the **Multiplication Principle (or Fundamental Counting Principle)**.
-   **Principle:** If there are $n_1$ ways to make the first choice, $n_2$ for the second, and so on, the total number of ways is $n_1 \times n_2 \times ...$
-   **Calculation:** Total possibilities = (roof choices) × (color choices) × (seat choices) × (trim choices) × (wheel choices)
    -   Total = 4 × 13 × 7 × 6 × 6 = 13,104.

#### R Code (if needed)

```{r}
4 * 13 * 7 * 6 * 6
```

------------------------------------------------------------------------

## Question 33

At a lottery, 59 tickets were sold and three prizes are to be given. a. How many possible outcomes are there if the three prizes are equivalent? b. How many possible outcomes are there if there is a first, second, and third prize? ------------------------------------------------------------------------

#### **Answer to Question 33**

**A. Final Answers:** \* (a) If prizes are equivalent (order doesn't matter), there are **32,509** possible outcomes (combinations). \* (b) If prizes are distinct (order matters), there are **195,054** possible outcomes (permutations).

**B. Work:** \* **(a) Equivalent prizes:** The order in which the winners are chosen doesn't matter. This is a **combination**. - Formula: ${}_{n}C_{r} = \binom{n}{r} = \frac{n!}{r!(n-r)!}$ - Calculation: ${}_{59}C_{3} = \frac{59!}{3!(56)!} = \frac{59 \times 58 \times 57}{3 \times 2 \times 1} = 32,509$. \* **(b) Distinct prizes:** The order matters (1st, 2nd, 3rd are different). This is a **permutation**. - Formula: ${}_{n}P_{r} = \frac{n!}{(n-r)!}$ - Calculation: ${}_{59}P_{3} = \frac{59!}{56!} = 59 \times 58 \times 57 = 195,054$.

**C. R Code:**

```{r}
# (a) Combination (order doesn't matter)
choose(59, 3)

# (b) Permutation (order matters)
# 59P3 = 59! / (59-3)! = 59! / 56!
factorial(59) / factorial(56)
# Or simply: 59 * 58 * 57
59 * 58 * 57
```

------------------------------------------------------------------------

## Question 34

An image in a popular magazine included the probability of a "Venus throw," one in which the outcome of tossing four balanced dice results in four different numbers. Determine that probability.

------------------------------------------------------------------------

#### **Answer to Question 34**

#### Final Answer

The probability of a "Venus throw" is approximately 0.278 or about 27.8%.

#### Work (Show Your Steps)

-   **1. Total Possible Outcomes:** Each of the 4 dice has 6 possible outcomes. By the multiplication principle, the total number of outcomes is $6 \times 6 \times 6 \times 6 = 6^4 = 1296$.
-   **2. Favorable Outcomes (all different):**
    -   For the first die, there are 6 possible outcomes.
    -   For the second die, there are only 5 remaining outcomes (it can't be the same as the first).
    -   For the third die, there are 4 remaining outcomes.
    -   For the fourth die, there are 3 remaining outcomes.
    -   Total favorable outcomes = $6 \times 5 \times 4 \times 3 = 360$. This is also the permutation ${}_{6}P_{4}$.
-   **3. Probability:**
    -   P(Venus Throw) = (Favorable Outcomes) / (Total Outcomes) = 360 / 1296 = 5/18.

#### R Code (if needed)

```{r}
# Favorable outcomes
favorable <- 6 * 5 * 4 * 3
# Total outcomes
total <- 6^4

# Probability
probability <- favorable / total
probability
```

------------------------------------------------------------------------

## Question 35

A student takes a true-false test consisting of 8 questions. Assume that the student guesses at each question and find the probability that: a. the student gets at least one question correct. b. the student gets a 50% or better on the exam.

------------------------------------------------------------------------

#### **Answer to Question 35**

#### Final Answer

a)  The probability of getting at least one question correct is \~99.6%. b) The probability of getting a 50% or better (4 or more correct) is \~63.7%.

#### Work (Show Your Steps)

-   **Identify the problem type:** This is a **Binomial Distribution** problem.
    -   n = number of trials (questions) = 8
    -   p = probability of success (guessing correctly) = 0.5
    -   X = the number of correct answers.
-   **(a) At least one correct, P(X ≥ 1):**
    -   It's easier to use the complement rule: P(X ≥ 1) = 1 - P(X = 0).
    -   P(X=0) is the probability of getting all 8 wrong. P(X=0) = ${}_{8}C_{0} \times (0.5)^0 \times (0.5)^8 = 1 \times 1 \times 0.00390625 = 0.00390625$.
    -   P(X ≥ 1) = 1 - 0.00390625 = 0.99609375.
-   **(b) 50% or better, P(X ≥ 4):**
    -   50% of 8 questions is 4 questions. We need P(X=4) + P(X=5) + P(X=6) + P(X=7) + P(X=8).
    -   This is tedious to do by hand. We'll use R.

#### R Code (if needed)

```{r}
# Define n and p
n <- 8
p <- 0.5

# (a) P(X >= 1) = 1 - P(X=0)
prob_a <- 1 - dbinom(0, size=n, prob=p)
prob_a
# Or using pbinom: 1 - pbinom(0, size=n, prob=p)

# (b) P(X >= 4)
# This is 1 - P(X <= 3)
prob_b <- 1 - pbinom(3, size=n, prob=p)
prob_b
```

------------------------------------------------------------------------

## Question 36

Suppose T and Z are random variables. a. If $P(T>2.44)=0.07$ and $P(T<-2.44)=0.07$, obtain $P(-2.44\le T\le2.44)$. b. If $P(-1.29\le z\le1.29)=0.80$ and also $P(Z>1.29)=P(Z<-1.29)$, find $P(Z>1.29)$.

------------------------------------------------------------------------

#### **Answer to Question 36**

**A. Final Answers:** \* (a) **P(-2.44 ≤ T ≤ 2.44) = 0.86** \* (b) Assuming symmetry, **P(Z \> 1.29) = 0.10**

**B. Work:** \* **(a):** The total probability under a distribution is 1. The probability in the middle is 1 minus the probabilities in the two tails. - P(middle) = 1 - P(left tail) - P(right tail) = 1 - 0.07 - 0.07 = 0.86. \* **(b):** The total probability is 1. We are given the middle area is 0.80. The remaining probability is in the two tails. - Total tail probability = 1 - 0.80 = 0.20. - Since the tails are equal (due to symmetry), each tail is half of this total. - P(Z \> 1.29) = 0.20 / 2 = 0.10.

**C. R Code (arithmetic only):**

```{r}
# Part a
inside <- 1 - 0.07 - 0.07
# Part b
right_tail <- (1 - 0.80) / 2
inside; right_tail
```

------------------------------------------------------------------------

## Question 37

The table below shows the probability distribution of the random variable X. a. Find the mean of the random variable. b. Obtain the standard deviation of the random variable.

|   X    |  1  |  2  |  3  |
|:------:|:---:|:---:|:---:|
| P(X=x) | 0.4 | 0.1 | 0.5 |

------------------------------------------------------------------------

#### **Answer to Question 37**

#### Final Answer

a)  The mean (expected value) of X is 2.1. b) The standard deviation of X is approximately 0.877.

#### Work (Show Your Steps)

-   **(a) Mean (μ or E\[X\]):** $\mu = \sum [x \cdot P(X=x)]$
    -   $\mu = (1 \times 0.4) + (2 \times 0.1) + (3 \times 0.5) = 0.4 + 0.2 + 1.5 = 2.1$
-   **(b) Standard Deviation (σ):** First find the variance ($\sigma^2$), then take the square root.
    -   **Variance:** $\sigma^2 = \sum [(x - \mu)^2 \cdot P(X=x)]$
    -   $\sigma^2 = (1 - 2.1)^2 \times 0.4 + (2 - 2.1)^2 \times 0.1 + (3 - 2.1)^2 \times 0.5$
    -   $\sigma^2 = (-1.1)^2 \times 0.4 + (-0.1)^2 \times 0.1 + (0.9)^2 \times 0.5$
    -   $\sigma^2 = (1.21 \times 0.4) + (0.01 \times 0.1) + (0.81 \times 0.5) = 0.484 + 0.001 + 0.405 = 0.89$
    -   **Standard Deviation:** $\sigma = \sqrt{0.89} \approx 0.943$

#### R Code (if needed)

```{r}
x_vals <- c(1, 2, 3)
probs <- c(0.4, 0.1, 0.5)

# (a) Mean
mean_x <- sum(x_vals * probs)
mean_x

# (b) Variance and Standard Deviation
variance_x <- sum(((x_vals - mean_x)^2) * probs)
sd_x <- sqrt(variance_x)
variance_x
sd_x
```

------------------------------------------------------------------------

## Question 38

A game of chance is played on a wheel that contains 40 numbers (19 red, 19 black, 2 green). Suppose that you bet \$2 on black. If the ball lands on a black number, you win \$2; otherwise you lose your \$2. Let X be the amount you win. The probability distribution for X is as follows.

|   X    |   2   |  -2   |
|:------:|:-----:|:-----:|
| P(X=x) | 0.475 | 0.525 |

a.  Find the expected value of the random variable X.

b.  On average, how much will you lose per play?

c.  Approximately how much would you expect to lose if you bet \$2 on black 100 times? 1000 times?

d.  

    ## Is the game profitable to play? Explain.

#### **Answer to Question 38**

#### Final Answer

The expected value of one play is -\$0.20, meaning you lose 20 cents on average per game. The game is not profitable.

#### Work (Show Your Steps)

-   **(a) Expected Value E\[X\]:** $\mu = \sum [x \cdot P(X=x)]$
    -   $E[X] = (2 \times 0.475) + (-2 \times 0.525) = 0.95 - 1.05 = -0.10$.
    -   *Correction based on problem statement*: The win is \$2, not the net. Net win is +\$2. Net loss is -\$2.
    -   $E[X] = (2 \times \frac{19}{40}) + (-2 \times \frac{21}{40}) = (2 \times 0.475) + (-2 \times 0.525) = 0.95 - 1.05 = -0.10$. Okay, the table is correct. My mistake. Wait... the question is "win \$2". Does that mean you get your \$2 bet back plus \$2? Let's assume X is the *net* winnings.
    -   Let's re-read. "you win \$2". This usually means net profit. Let's stick with the provided table. $E[X] = (2 \times 0.475) + (-2 \times 0.525) = 0.95 - 1.05 = -0.10$.
-   **b. Average loss per play:** The expected value is the long-run average. You lose, on average, \$0.10 per play.
-   **c. Expected loss over many plays:**
    -   100 times: 100 × (-\$0.10) = -\$10. You expect to lose \$10.
    -   1000 times: 1000 × (-\$0.10) = -\$100. You expect to lose \$100.
-   **d. Profitability:** The game is not profitable for the player because the expected value is negative. In the long run, you are guaranteed to lose money.

#### R Code (if needed)

```{r}
# Provided distribution
outcomes <- c(2, -2)
probabilities <- c(19/40, 21/40) # 19 black, 21 not black (19 red + 2 green)

# a. Expected Value
expected_value <- sum(outcomes * probabilities)
expected_value

# c. Expected loss for 100 and 1000 plays
loss_100 <- 100 * expected_value
loss_1000 <- 1000 * expected_value
loss_100
loss_1000
```

------------------------------------------------------------------------

## Question 39

A factory manager collected data on the number of equipment breakdowns per day. From those data, she derived the probability distribution shown to the right, where W denotes the number of breakdowns on a given day.

|   W    |  0   |  1   |  2   |
|:------:|:----:|:----:|:----:|
| P(W=w) | 0.85 | 0.10 | 0.05 |

a.  Determine $\mu_{W}$ and $\sigma_{W}$.

b.  On average, how many breakdowns occur per day?

c.  

    ## About how many breakdowns are expected during a 1-year period, assuming 250 work days per year?

#### **Answer to Question 39**

#### Final Answer

The mean is 0.2 breakdowns per day with a standard deviation of \~0.529. Over a 250-day year, about 50 breakdowns are expected.

#### Work (Show Your Steps)

-   **(a) Mean and Standard Deviation:**
    -   **Mean:** $\mu_W = (0 \times 0.85) + (1 \times 0.10) + (2 \times 0.05) = 0 + 0.10 + 0.10 = 0.20$.
    -   **Variance:** $\sigma_W^2 = (0-0.2)^2(0.85) + (1-0.2)^2(0.10) + (2-0.2)^2(0.05) = (0.04)(0.85) + (0.64)(0.10) + (3.24)(0.05) = 0.034 + 0.064 + 0.162 = 0.26$.
    -   **Std Dev:** $\sigma_W = \sqrt{0.26} \approx 0.5099$.
-   **(b) Average breakdowns:** This is the mean, which is 0.2 breakdowns per day.
-   **(c) Expected in 1 year:** (Breakdowns per day) × (Work days) = 0.2 × 250 = 50.

#### R Code (if needed)

```{r}
w_vals <- c(0, 1, 2)
w_probs <- c(0.85, 0.10, 0.05)

# a. Mean and Std Dev
mean_w <- sum(w_vals * w_probs)
var_w <- sum(((w_vals - mean_w)^2) * w_probs)
sd_w <- sqrt(var_w)
mean_w
sd_w

# c. Expected in 1 year
expected_yearly <- mean_w * 250
expected_yearly
```

------------------------------------------------------------------------

## Question 40

Evaluate the binomial coefficient below. $$ \binom{10}{6} $$

------------------------------------------------------------------------

#### **Answer to Question 40**

#### Final Answer

The binomial coefficient $\binom{10}{6}$ is equal to 210.

#### Work (Show Your Steps)

-   **Formula:** $\binom{n}{k} = \frac{n!}{k!(n-k)!}$
-   **Calculation:** $\binom{10}{6} = \frac{10!}{6!(10-6)!} = \frac{10!}{6!4!} = \frac{10 \times 9 \times 8 \times 7}{4 \times 3 \times 2 \times 1} = 10 \times 3 \times 7 = 210$.
-   **Interpretation:** This is the number of ways to choose 6 items from a set of 10 where order does not matter.

#### R Code (if needed)

```{r}
# R has a built-in function for this
choose(10, 6)
```

------------------------------------------------------------------------

## Question 41

If we repeatedly toss a balanced coin, then, in the long run, it will come up heads about half the time. But what is the probability that such a coin will come up heads exactly half the time in 20 tosses?

------------------------------------------------------------------------

#### **Answer to Question 41**

#### Final Answer

The probability of getting exactly 10 heads in 20 tosses of a balanced coin is approximately 0.176 or 17.6%.

#### Work (Show Your Steps)

-   **Identify the problem type:** Binomial distribution.
    -   n = 20 (tosses)
    -   p = 0.5 (probability of heads)
    -   x = 10 (exactly half)
-   **Formula:** $P(X=x) = \binom{n}{x} p^x (1-p)^{n-x}$
-   **Calculation:** $P(X=10) = \binom{20}{10} (0.5)^{10} (0.5)^{10} = \frac{20!}{10!10!} (0.5)^{20} = 184756 \times (0.5)^{20} \approx 0.1762$.

#### R Code (if needed)

```{r}
# Use the dbinom for "exactly"
dbinom(x=10, size=20, prob=0.5)
```

------------------------------------------------------------------------

## Question 42

According to an article, 46% of adults have experienced a breakup at least once during the last 10 years. Of nine randomly selected adults, find the probability that the number, X, who have experienced a breakup at least once during the last 10 years is: a. exactly five; at most five; at least five. b. at least one; at most one. c. between four and six, inclusive. d. Determine the probability distribution of the random variable X. e. Strictly speaking, why is the probability distribution that you obtained in part (d) only approximately correct? What is the exact distribution called? ------------------------------------------------------------------------

#### **Answer to Question 42**

**A. Setup:** This is a Binomial problem where X \~ Binomial(n = 9, p = 0.46).

**B. Final Answers (showing R):** - (a) P(X=5) ≈ 0.207; P(X≤5) ≈ 0.814; P(X≥5) ≈ 0.393 - (b) P(X≥1) ≈ 0.995; P(X≤1) ≈ 0.040 - (c) P(4≤X≤6) ≈ 0.630

**C. R Code with answers:**

```{r}
n <- 9
p <- 0.46

# (a) Exactly 5; at most 5; at least 5
dbinom(5, size=n, prob=p)                 # P(X = 5)
pbinom(5, size=n, prob=p)                 # P(X <= 5)
1 - pbinom(4, size=n, prob=p)             # P(X >= 5)

# (b) At least one; at most one
1 - pbinom(0, size=n, prob=p)             # P(X >= 1)
pbinom(1, size=n, prob=p)                 # P(X <= 1)

# (c) Between 4 and 6 inclusive: P(X=4) + P(X=5) + P(X=6)
sum(dbinom(c(4, 5, 6), size=n, prob=p))

# (d) Probability distribution of X (x = 0..9)
x_values <- 0:9
prob_dist <- dbinom(x_values, size=n, prob=p)
# Display as a table
data.frame(x = x_values, P_X_is_x = prob_dist)
```

**E. Why only approximate?** The Binomial distribution assumes that trials are **independent** and the probability of success `p` is constant. When we sample adults from a population *without replacement*, the trials are not strictly independent (the probability changes slightly after each person is picked). - The **exact** distribution for this scenario is the **Hypergeometric distribution**. - However, when the population is very large compared to the sample size (as it is here), the Binomial distribution is an excellent and much simpler approximation.

------------------------------------------------------------------------

## Question 43

According to tables provided by the U.S. National Center for Health Statistics, there is roughly an 80% chance that a person aged 20 will be alive at age 65. Suppose that three people aged 20 are selected at random. Find the probability that the number alive at age 65 will be at most one.

------------------------------------------------------------------------

#### **Answer to Question 43**

#### Final Answer

The probability that at most one of the three people will be alive at age 65 is 0.104 or 10.4%.

#### Work (Show Your Steps)

-   **Identify the problem type:** Binomial distribution.
    -   n = 3 (people selected)
    -   p = 0.80 (probability of being alive at 65, a "success")
    -   X = number of people alive at 65.
-   **Goal:** Find P(X ≤ 1), which means P(X=0) + P(X=1).
-   **Calculate P(X=0):** None are alive. This means 3 "failures." The probability of failure is 1 - 0.8 = 0.2.
    -   P(X=0) = $\binom{3}{0}(0.8)^0(0.2)^3 = 1 \times 1 \times 0.008 = 0.008$.
-   **Calculate P(X=1):** Exactly one is alive.
    -   P(X=1) = $\binom{3}{1}(0.8)^1(0.2)^2 = 3 \times 0.8 \times 0.04 = 0.096$.
-   **Total Probability:** P(X ≤ 1) = 0.008 + 0.096 = 0.104.

#### R Code (if needed)

```{r}
# "At most one" is P(X <= 1), which is pbinom
pbinom(q=1, size=3, prob=0.8)
# We can verify by adding P(X=0) and P(X=1)
dbinom(0, size=3, prob=0.8) + dbinom(1, size=3, prob=0.8)
```

# End of main content. Append R quick reference for students.

------------------------------------------------------------------------

## R Quick Reference — Binomial (Beginner)

**When to use:** Counting successes in a fixed number of independent trials with constant probability `p`.

-   **Exactly x** successes: `dbinom(x, size = n, prob = p)`
-   **At most x**: `pbinom(x, size = n, prob = p)`
-   **At least x**: `1 - pbinom(x - 1, size = n, prob = p)`
-   **Quantile** (inverse CDF): `qbinom(prob, size = n, prob = p)`
-   **Simulate** m experiments: `rbinom(m, size = n, prob = p)`

**Example** (n = 6, p = 0.40):

```{r}
# Exactly 3: P(X = 3)
dbinom(3, size = 6, prob = 0.40)
# At most 3: P(X ≤ 3)
pbinom(3, size = 6, prob = 0.40)
# At least 3: P(X ≥ 3)
1 - pbinom(2, size = 6, prob = 0.40)
```

------------------------------------------------------------------------

## R Quick Reference — Poisson (Beginner)

**When to use:** Counting events in a fixed interval/region with average rate `lambda = λ`.

-   **Exactly x** events: `dpois(x, lambda)` *(Use this when a question says **“Exactly”**)*
-   **At most x**: `ppois(x, lambda)`
-   **At least x**: `1 - ppois(x - 1, lambda)`
-   **Quantile** (inverse CDF): `qpois(prob, lambda)`
-   **Simulate** m intervals: `rpois(m, lambda)`

**Example** (λ = 2.5):

```{r}
# Exactly 3: P(X = 3) 
dpois(3, lambda = 2.5) 
# At most 3: P(X ≤ 3) 
ppois(3, lambda = 2.5) 
# At least 3: P(X ≥ 3) 
1 - ppois(2, lambda = 2.5)
```

```{r}
mean(8,15,3,4,5)
```

<hr>
<center>
**Resource made by Prof. Vinay Kodipelly for MATH 1320**
</center>
