Question 1

A bag contains 3 red balls and 2 green balls. 2 balls are selected at random from the bag at the same time. What is the probability of drawing two different colors?

bag <- c(rep("Red",3),rep("Green",2))
N <- 1e5
counter <- 0
for (i in 1:N) {
  draws <- sample(x = bag,size = 2,replace = T)
  if (draws[1] != draws[2]) {
    counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability is:",probability,"\n")
## The probability is: 0.48198

Question 2

Solve the system of equations below.

\[5x + 4y = 18 \\ 6x - 11y = -89\]

q2_data <- data.frame(X = c(5,6),
                      Y = c(4,-11),
                      Constants = c(18,-89))
q2_model <- lm(Constants ~ . - 1,data = q2_data)
coef(q2_model)
##  X  Y 
## -2  7