DSC 011 S26 Lab 4

Statistical Variables; Combinatorics: Factorials and Binomial Coefficients

Author

Leo Garcia Ortiz

Published

February 20, 2026

Initial Set-Up

Preliminaries: Assignment of Teams and Team Tables

The class will split into OS-specific randomly assigned teams of about seven. The teams and team tables are determined by random sampling without replacement (also known as permutation) as follows:


# 70 students as of Feb 18
windows11 <- c("aflores-hernandez","akwong25","bdelacruz-angeles",
               "bhernandezarteaga","cbettencourt2","cchen271","cornelas3",
               "craigelijaesoriano","davila-castaneda","dvargas38",
               "ecastillo-quevedo","efernando","ekjotjohal","elliottwhitney",
               "fromerobojorquez","genaxiong","ggonzalez-ramirez",
               "ghendrickson","gurindersahota","jasminesamayoa",
               "jcontrerastrinidad","jessiemorales","jlegaspina","joneal2",
               "jwong290","kchen129","leogarciaortiz","lillieyang",
               "lindaespinozamunoz","lorenackerman","mdesilva","rbujji",
               "roderickma","skodur","sraman7","tolaniyan","trevoroh")

macOS <- c("adimasagurto","ahmiyasalter","alannahtanner","aleroux",
          "alizeibarra","apatterson9","asingh368",
          "eflores136","elmermartinez","emendozagonzalez",
          "emoya8","isidrohernandez","jaisingh","jangel15","jardindo",
          "jessecaclark","jmandujano4","jperez460","kamryntaylor",
          "kchen132","kvu56","lalagos","malachifuqua","manroopkaur",
          "mayraarias","msuccari","omarkhalil","rbeattie","seanjimenez",
          "vchezhiyan","xcortes2")


language_table_students <- c("edmondcheng", "angeliachunyu")
teamsize  <- 7

# Set seed for reproducibility
set.seed("20260218")
shuffled_win11  <- sample(windows11, replace = FALSE)
tables    <- c(rep(1:3,each=teamsize),rep(4:5,each=(teamsize+1)))
teams_win11     <- split(shuffled_win11, tables)


shuffled_macOS  <- sample(macOS, replace = FALSE)
tables    <- c(rep(6,(teamsize-1)),rep(7,(teamsize-2)),rep(8:9,each=teamsize),rep(10,(teamsize-1)))
teams_macOS   <- split(shuffled_macOS, tables)
teams_macOS$`7` <- c(teams_macOS$`7`,language_table_students)

teams <- lapply(c(teams_win11,teams_macOS),sort)

invisible(lapply(seq_along(teams), function(i) {
  cat("Team at Table", i, ":", teams[[i]], "\n")
}))
## Team at Table 1 : bdelacruz-angeles davila-castaneda genaxiong jlegaspina jwong290 lillieyang tolaniyan 
## Team at Table 2 : aflores-hernandez akwong25 craigelijaesoriano ecastillo-quevedo fromerobojorquez ggonzalez-ramirez gurindersahota 
## Team at Table 3 : efernando elliottwhitney leogarciaortiz lindaespinozamunoz mdesilva rbujji skodur 
## Team at Table 4 : bhernandezarteaga cbettencourt2 cchen271 cornelas3 ghendrickson jcontrerastrinidad roderickma trevoroh 
## Team at Table 5 : dvargas38 ekjotjohal jasminesamayoa jessiemorales joneal2 kchen129 lorenackerman sraman7 
## Team at Table 6 : apatterson9 asingh368 jaisingh jessecaclark jperez460 kamryntaylor 
## Team at Table 7 : ahmiyasalter alannahtanner angeliachunyu edmondcheng kchen132 lalagos seanjimenez 
## Team at Table 8 : aleroux eflores136 elmermartinez emoya8 jangel15 jmandujano4 rbeattie 
## Team at Table 9 : adimasagurto emendozagonzalez jardindo kvu56 malachifuqua omarkhalil vchezhiyan 
## Team at Table 10 : alizeibarra isidrohernandez manroopkaur mayraarias msuccari xcortes2

Acknowledgements

In this section please explicitly acknowledge by name the teammates or AI agents that helped you work this assignment, and please briefly describe how they helped you.

  1. Team-mate1 pointed out the man page…
  2. Team-mate2 showed me where to download…
  3. I used ChatGPT to check my code syntax…

Instructions for Completing and Submitting This Assignment

  1. Download and open today’s template notebook in RStudio
  2. Personalize the file by writing your name in the YAML header (replace “FirstName LastName”) — be sure to do this or you will lose points!
  3. Save with your name in RStudio and move to course directory: In RStudio select File → Save as..., find your course directory files and move and rename the file to include your name (e.g., FirstName_LastName_DataTypes_Quiz.qmd)
  4. Render to HTML
  5. Follow instructions from the HTML rendered output by editing your personalized notebook.
  6. As you work the assignment, keep rendering and editing the file, asking for help from your team until you get all CORRECT for each problem. Two or more students may ask for help from the instructors.
  7. Acknowledge Help and Render to HTML and submit to Catcourses. Acknowledge those that help you above, and turn in as much CORRECT work as you can by the end of class today. Submission by end of class qualifies you for credit.
  8. Resubmit your best work by midnight tonight for better grade or fully accepted work – only your latest and best work gets graded.

Assignment

Statistical Variables

  1. In the R Console, look at the iris dataset in R (to print only the first few rows, try head(iris)). Which of the statistical variables is categorical? Enclose your answer in double quotes (") and use the exact name of the variable as shown (case-sensitive).
answer <- "Species"
print_and_check(answer,"5c5ff5bee3495009617c9244cdb23ce5")
## [1] "Species"
## [1] "CORRECT"
  1. For the variable you identified in the last section, is this variable “ordinal” or “nominal”?
answer <- "nominal"
print_and_check(answer,"be6d2c8bd4612086ca6dfbe8d261dfc1")
## [1] "nominal"
## [1] "CORRECT"
  1. In the R Console, look at the Puromycin dataset in R (to print only the first few rows, try head(Puromycin)). Are the conc and rate variables "ratio" or “interval” valued? Enclose your answer in double quotes (") and use all lower case.
answer <- "ratio"
print_and_check(answer,"e5940e66001bd294ac109a3b5cf2fd14")
## [1] "ratio"
## [1] "CORRECT"
  1. Which of the variables in the Puronmycin “categorical nominal”?
answer <- "state"
print_and_check(answer, "6b8322a90264384dbe7d0900d34540a7")
## [1] "state"
## [1] "CORRECT"
  1. In a dataset, sunfish are assigned into groups by their intensity of pigmentation in a statistical variable called “Pigmentation,” which ranges from “0” meaning “No Pigmentation” to “4” meaning “Solid Pigmentation.” For example, a “2” means “moderately speckled.” What kind of statistical variable is this? (allowable choices are “discrete ratio”, “discrete interval”, “continuous ratio”, “continuous interval”, “categorical nominal” and “categorical ordinal”.
answer <- "categorical ordinal"
print_and_check(answer,"9108c33ac7446b111125157facf5511b")
## [1] "categorical ordinal"
## [1] "CORRECT"

Computing Sample Sizes in R

What is the sample size of the Nile dataset?

Use the length() function on the Nile dataset to find the sample size of this univariate (one-variable) dataset.

answer <- length(Nile)
print_and_check(answer,"5d6e7fe43b3b73e5fd2961d5162486fa")
## [1] 100
## [1] "CORRECT"

What is the sample size of the iris dataset?

In the R Console, use the str() function on the iris dataset to find the sample size/number of observations in this multivariate (multiple variable) dataset. Examine the output and enter the correct value here below.

answer <- "150<-length(iris)"
print_and_check(answer,"214279b7439fabef07263ceee022cbd6")
## [1] "150<-length(iris)"
## [1] "INCORRECT"

Counting Permutations and Combinations of Cell Dishes

  1. In the R Console, practice using the R factorial function factorial() function to compute the number of all possible orders of 8 individually labelled cell line dishes. Once you are satisfied, edit the following code chunk to set answer to the return value of \(8!\), that is 8 factorial:
answer <- factorial(8)
print_and_check(answer,"5fe17213635d687325a0417fa98f0c49")
## [1] 40320
## [1] "CORRECT"
  1. Edit the following code chunk to set answer to the return value of \(4!\), that is 4 factorial:
answer <- factorial(4)
print_and_check(answer,"ce9138d620d52a87492a6093b34eec23")
## [1] 24
## [1] "CORRECT"
  1. After the assignment of the 8 cell dishes to the two treatment conditions, the order of the cell dishes within each of the two treatment conditions does not matter. Express the total number of ways to assign the 8 dishes to the two treatments evenly using an R expression using the ratio operator / and three instances of the factorial() function.
answer <- factorial(8)/factorial(4)**2
print_and_check(answer,"2a560fd9a59ef8af4b1f1b40af6ab40d")
## [1] 70
## [1] "CORRECT"
  1. Use the R choose() function to express the number of ways that 5 of 10 cell dishes could be independently assigned to two treatments evenly:
answer <- "NULL"
print_and_check(answer,"295e8d8d3668754517a5f6ebedb367a1")
## [1] "NULL"
## [1] "INCORRECT"

Probabilities by the Counting Measure

  1. If each of different treatment assignments from the previous problem is equally likely, what is the probability of any one specific assignment of 5 dishes to the treatment condition? (assign probability with your R code, and don’t change the code using round() defining answer)
probability <- 0
answer <- round(probability,5)
print_and_check(answer,"aa37b8eb14c9b8e4195b63bc99489fcf")
## [1] 0
## [1] "INCORRECT"
  1. What is the probability of drawing a hand of four aces from a very well-shuffled full deck of 52 playing cards, if there are only 4 aces in a full deck? (assign probability with your R code, and don’t change the code using round() defining answer)
probability <- 0
answer <- round(probability,7)
print_and_check(answer,"38d4f0f672da42cc139067f6fe0832dc")
## [1] 0
## [1] "INCORRECT"

Conditional Probability and Statistical Independence

  1. What is the conditional probability of “rolling a seven or 11” with two fair dice, conditional on the event that one or both of the dice shows a 1?
probability <- 0
answer <- round(probability,4)
print_and_check(answer,"354e257ec8e8a32f7e0e0ead838ebda7")
## [1] 0
## [1] "INCORRECT"
  1. Suppose that in a statistical population of men, the probability of Chlamydia infection is 0.04 and the probability of infection with HPV is 0.12. What is the probability of coinfection with HPV and Chlamydia if infection with HPV and Chlamydia are independent in this population?
probability <- 0
answer <- round(probability,4)
print_and_check(answer,"e61488630ab3ce29ab3592027e7958d3")
## [1] 0
## [1] "INCORRECT"