Untitled document (7)

.pdf

School

University of Houston *

*We aren’t endorsed by this school

Course

1311

Subject

Industrial Engineering

Date

Apr 3, 2024

Type

pdf

Pages

10

Uploaded by rashusha505 on coursehero.com

HW 3 #1(a) plot(NA, xlim = c(-3, 3), ylim = c(-3, 3), xlab = "X1", ylab = "X2") # X1 - 2 * X2 = 0 abline(h = 0, col = "blue") # X1 - 2 * X2 > 0 (above the line) red dots points(0, 2, pch = 19, col = "red") # Point (0, 2) points(2, 1, pch = 19, col = "red") # Point (2, 1) # X1 - 2 * X2 < 0 (below the line) green triangles points(0, -2, pch = 17, col = "green") # Point (0, -2) #points text(0, 2, "X1 = 0, X2 = 2", pos = 2) text(2, 1, "X1 = 2, X2 = 1", pos = 2) text(0, -2, "X1 = 0, X2 = -2", pos = 2) # legend legend("topright", legend = c("Hyperplane", "X1 - 2*X2 > 0", "X1 - 2*X2 < 0"), col = c("blue", "red", "green"), pch = c(-1, 19, 17))
#1(b) plot(NA, xlim = c(-3, 3), ylim = c(-3, 3), xlab = "X1", ylab = "X2") # X1 + X2 - 2 = 0 abline(a = 2, b = -1, col = "blue") # X1 + X2 - 2 > 0 (above the line) red dots points(1, 1, pch = 19, col = "red") # Point (1, 1) # X1 + X2 - 2 < 0 (below the line) green triangles points(-1, -1, pch = 17, col = "green") # Point (-1, -1) points(1, 1, pch = 17, col = "green") # Point (1, 1) # points text(1, 1, "X1 = 1, X2 = 1", pos = 2) text(-1, -1, "X1 = -1, X2 = -1", pos = 2) #legend legend("topright", legend = c("Hyperplane", "X1 + X2 - 2 > 0", "X1 + X2 - 2 < 0"), col = c("blue", "red", "green"), pch = c(-1, 19, 17))
#2(a/b) plot(NA, NA, xlim = c(-10, 10), ylim = c(-10, 10), xlab = "X1", ylab = "X2") curve(sqrt(9 - (1 + x)^2) + 2, from = -10, to = 10, col = "blue", lwd = 2, add = TRUE) curve(-sqrt(9 - (1 + x)^2) + 2, from = -10, to = 10, col = "blue", lwd = 2, add = TRUE) curve(sqrt(16 - (1 + x)^2) + 2, from = -10, to = 10, col = "red", lwd = 2, add = TRUE) curve(-sqrt(16 - (1 + x)^2) + 2, from = -10, to = 10, col = "red", lwd = 2, add = TRUE) # labels for the curves text(2, 7, "Circle with r = 3", col = "blue", pos = 4) text(2, -5, "Circle with r = 4", col = "red", pos = 4) # Create points X1_points <- seq(-10, 10, by = 0.1) X2_points <- seq(-10, 10, by = 0.1) # values of the expressions for the points expression_values <- outer(X1_points, X2_points, FUN = function(x1, x2) (1 + x1)^2 + (2 - x2)^2) points(X1_points[expression_values > 16], X2_points[expression_values > 16], pch = 19, col = "blue") points(X1_points[expression_values >= 9 & expression_values <= 16], X2_points[expression_values >= 9 & expression_values <= 16], pch = 19, col = "red") points(X1_points[expression_values < 9], X2_points[expression_values < 9], pch = 19, col = "white") # legend legend("topright", legend = c("Expression > 16", "9 <= Expression <= 16", "Expression < 9"), col = c("blue", "red", "white"), pch = 19) #2(c)
(1+X1)^2+(2-X2)^2 For (0,0) (1+0)^2+(2-0)^2=5 9<=5<=16(false) 5 is not greater than 9 therefore, it is classified as RED For (-1,1) (1+(-1))^2+(2-1)^2=1 9<=1<=16(false) 1 is not greater than 9 therefore, it is classified as RED For (2,2) (1+2)^2+(2-2)^2=9 9<=9<=16(true) 9 is = to 9 and greater than 16 therefore, it is classified as BLUE For (3,4) (1+3)^2+(2-4)^2=20 9<=20<=16(false) 20 is not less than 16, therefore it is classified as RED #2(d) (1+X1)^2+(2-X2)^2=16 X1^2+2X1+X2^2-4X^2=11 (expanded) We can see that each coefficient of the variables X1 and X2 have a constant multiplier of one of the terms involving them therefore, X1,X2,X1^2,X2^2 are linear combination of these variables. #3(a/b) X1 = c(1, 3, 4, 2, 4, 4, 1, 1) X2 = c(4, 4, 3, 2, 2, 4, 2, 3) Y = factor(c("Blue", "Red", "Red", "Blue", "Red", "Red", "Blue", "Blue")) plot(X1, X2, col = Y, xlim = c(0, 5), ylim = c(0, 5),main = "Optimal Separating Hyperplane") slope=1/3 abline(0.5,1)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help