Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding more resources #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ESC201/Assignments/Assignment 1.pdf
Binary file not shown.
Binary file added ESC201/Assignments/Assignment 10.pdf
Binary file not shown.
Binary file added ESC201/Assignments/Assignment 11.pdf
Binary file not shown.
Binary file added ESC201/Assignments/Assignment 12.pdf
Binary file not shown.
Binary file added ESC201/Assignments/Assignment 2.pdf
Binary file not shown.
Binary file added ESC201/Assignments/Assignment 3.pdf
Binary file not shown.
Binary file added ESC201/Assignments/Assignment 4.pdf
Binary file not shown.
Binary file added ESC201/Assignments/Assignment 5.pdf
Binary file not shown.
Binary file added ESC201/Assignments/Assignment 6.pdf
Binary file not shown.
Binary file added ESC201/Assignments/Assignment 7.pdf
Binary file not shown.
Binary file added ESC201/Assignments/Assignment 8.pdf
Binary file not shown.
Binary file added ESC201/Assignments/Assignment 9.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added ESC201/FCH.pdf
Binary file not shown.
Binary file added ESC201/Slides/.DS_Store
Binary file not shown.
Binary file added ESC201/Slides/Lecture 01.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 02.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 03.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 04.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 05.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 06.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 07.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 08.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 09.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 10.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 11.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 12.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 13.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 14.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 15.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 16.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 17.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 18.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 19.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 20.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 21.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 22.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 23.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 24.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 25.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 26.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 27.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 28.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 29.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 30.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 31.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 32.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 33.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 34.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 35.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 36.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 37.pdf
Binary file not shown.
Binary file added ESC201/Slides/Lecture 38.pdf
Binary file not shown.
Binary file added MSO202/Assigments/assignemnt_0.pdf
Binary file not shown.
Binary file added MSO202/Assigments/assignemnt_1.pdf
Binary file not shown.
Binary file added MSO202/Assigments/assignemnt_2.pdf
Binary file not shown.
Binary file added MSO202/Assigments/assignemnt_3.pdf
Binary file not shown.
Binary file added MSO202/Assigments/assignemnt_4.pdf
Binary file not shown.
Binary file added MSO202/Assigments/assignemnt_5.pdf
Binary file not shown.
Binary file added MSO202/Assigments/assignment_6.pdf
Binary file not shown.
Binary file added MSO202/Assignment Solutions/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added MSO202/Books/Advanced mathematics.pdf
Binary file not shown.
Binary file added MSO202/Books/CHURCHILL.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/.DS_Store
Binary file not shown.
Binary file added MSO202/Lecture Notes/Goursat_s_theorem.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/complex_log.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture01_29.07.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture02_03.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture03_04.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture04_05.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture05_10.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture06_11.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture07_12.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture08_18.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture09_20.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture10_24.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture11_25.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture12_26.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture13_31.08.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture14_01.09.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture15_02.09.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture16_07.09.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture17_08.09.2022.pdf
Binary file not shown.
Binary file added MSO202/Lecture Notes/lecture18_09.09.2022.pdf
Binary file not shown.
Binary file added MSO202/MSO202A_FCH.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions MSO202/Site.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href="https://sites.google.com/view/mso202a/home"> Click Here</a>
Binary file added MSO205/.DS_Store
Binary file not shown.
Binary file added MSO205/MSO205A_FCH.pdf
Binary file not shown.
Binary file added MSO205/Past Papers/.DS_Store
Binary file not shown.
Binary file added MSO205/Past Papers/Midsem/Midsem Question.pdf
Binary file not shown.
Binary file added MSO205/Past Papers/Midsem/Midsem Solution Part1.pdf
Binary file not shown.
Binary file added MSO205/Past Papers/Midsem/Midsem Solution Part2.pdf
Binary file not shown.
Binary file added MSO205/Past Papers/Quizes/Quiz 1.pdf
Binary file not shown.
Binary file added MSO205/Past Papers/Quizes/Quiz 2 Questions.pdf
Binary file not shown.
Binary file added MSO205/Past Papers/Quizes/Quiz 2 Solution Part1.pdf
Binary file not shown.
Binary file added MSO205/Past Papers/Quizes/Quiz 2 Solution Part2.pdf
Binary file not shown.
Binary file added MSO205/Past Papers/Quizes/Quiz 3 Questions.pdf
Binary file not shown.
Binary file added MSO205/Past Papers/Quizes/Quiz 3 Solutions.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 01 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 02 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 03 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 04 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 05 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 06 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 07 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 08 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 09 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 10 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 11 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 12 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Solutions/Week 13 Solution.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 08.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 09.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 1.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 10.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 11.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 12.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 13.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 2.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 3.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 4.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 5.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 6.pdf
Binary file not shown.
Binary file added MSO205/Practice Set/Week 7.pdf
Binary file not shown.
Binary file added MSO205/Reference Material/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added MSO205/Supplymentary Material/.DS_Store
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week01.pdf
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week02.pdf
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week03.pdf
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week04.pdf
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week05.pdf
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week06.pdf
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week07.pdf
Binary file not shown.
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week08.pdf
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week09.pdf
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week10.pdf
Binary file not shown.
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week11.pdf
Binary file not shown.
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week12.pdf
Binary file not shown.
Binary file added MSO205/Supplymentary Material/Week13.pdf
Binary file not shown.
Binary file added MTH207/Lecture Slides/01. Generalised Inverse.pdf
Binary file not shown.
Binary file added MTH207/Lecture Slides/02. Projection.pdf
Binary file not shown.
Binary file added MTH207/Lecture Slides/03. Derivatives.pdf
Binary file not shown.
Binary file added MTH207/Lecture Slides/04. Optimization.pdf
Binary file not shown.
Binary file added MTH207/Lecture Slides/05. Linear Model I.pdf
Binary file not shown.
Binary file added MTH207/Lecture Slides/06. Linear Model II.pdf
Binary file not shown.
Binary file added MTH207/Lecture Slides/07. Linear Model III.pdf
Binary file not shown.
Binary file added MTH207/Lecture Slides/08. Linear Model IV.pdf
Binary file not shown.
Binary file added MTH207/Problem Set/Assignment 1.pdf
Binary file not shown.
Binary file added MTH207/Problem Set/Assignment 2.pdf
Binary file not shown.
Binary file added MTH207/Problem Set/Assignment 3.pdf
Binary file not shown.
Binary file added MTH207/Problem Set/Assignment 4.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added MTH208/.DS_Store
Binary file not shown.
Binary file added MTH208/208_FCH.pdf
Binary file not shown.
Binary file added MTH208/Assignments/.DS_Store
Binary file not shown.
35 changes: 35 additions & 0 deletions MTH208/Assignments/assign1_sol (1).R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

################ my code ############
my.tennis <- function(p)
{

# will track number of wins for A and B
A <- 0
B <- 0
for(k in 1:5)
{
next.game <- sample(0:1, size = 1, prob = c(p, 1-p))
if(next.game == 0) B <- B+1
if(next.game == 1) A <- A+1

# best-of-series finishes when any team reaches 3
if(A == 3 || B == 3)
{
x <- k
break
}
}
return(x)
}


my.matches <- numeric(length = 1e3)
for(i in 1:1e3)
{
my.matches[i] <- my.tennis(.7)
}

ans <- mean(my.matches)
ans

###################################
21 changes: 21 additions & 0 deletions MTH208/Assignments/assign2_sol (2).R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

################ my code ############
my.prop.color <- function(img, col)
{
col.mat <- as.array(img[,,1,])
dims <- dim(col.mat)

dist <- matrix(0, nrow = dims[1], ncol = dims[2])
for(i in 1:dims[1])
{
for(j in 1:dims[2])
{
dist[i,j] <- norm(col.mat[i,j, ] - col, "2")
}
}

props <- sum(dist < .5)/(dims[1]*dims[2])
return(props)
}

###################################
18 changes: 18 additions & 0 deletions MTH208/Assignments/assign3_sol.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

library(rvest)
html <- read_html("https://www.icc-cricket.com/rankings/womens/player-rankings/odi/batting")

# Get the whole data as a table
# First element in the list
tab <- html_table(html)[[1]]

# Replace first column with 1:100
tab$Pos <- 1:100

# Remove last column
tab <- tab[, -5]

# convert to data.frame
# this step is not very necessary
MY_icc_rank <- as.data.frame(tab)

13 changes: 13 additions & 0 deletions MTH208/Assignments/assign4_sol.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
library(rvest)

html <- read_html("https://prsindia.org/covid-19/cases")

foo <- html %>% html_table()
foo <- foo[[1]]

MY_india_rates <- foo[-1, ]
MY_india_rates <- MY_india_rates[ ,-1]
MY_india_rates <- as.data.frame(MY_india_rates)

save(MY_india_rates, file = "covid.Rdata")

6 changes: 6 additions & 0 deletions MTH208/Assignments/assign5_sol.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

my.func2 <- function(vec)
{
temp <- log(vec)
return(temp/sum(temp))
}
22 changes: 22 additions & 0 deletions MTH208/Assignments/assign6_sol.cp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// cope and paste your code here.

#include <Rcpp.h>
using namespace Rcpp;


// [[Rcpp::export]]
NumericMatrix my_divideC(NumericMatrix x, NumericMatrix y) {
int n = x.nrow();
int m = x.ncol();

NumericMatrix out(n,m);

for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
out(i,j) = x(i,j) / y(i,j);
}
}
return out;
}
20 changes: 20 additions & 0 deletions MTH208/Assignments/assign7_sol.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Solution to assignment 7

dat <- read.csv("data.csv")
dat$X1 <- as.factor(dat$X1)
dat$X2 <- as.factor(dat$X2)
dat$X3 <- as.factor(dat$X3)

## X2 is the variable that separates Var1 and Var2
## into 3 visible groups

plot(dat$Var1, dat$Var2, col = dat$X2,
xlab = "Variable 1", ylab = "Variable 2",
main = "Simpson's Paradox with X2", pch = 16)
for(i in 1:length(levels(dat$X2)))
{
foo <- subset(dat, dat$X2 == levels(dat$X2)[i])
abline(lm(foo$Var2 ~ foo$Var1), col = i)
}
legend("topleft", legend = levels(dat$X2),
title = "X2", fill = 1:3)
Binary file added MTH208/Assignments/assignment1.pdf
Binary file not shown.
Binary file added MTH208/Assignments/assignment2.pdf
Binary file not shown.
Binary file added MTH208/Assignments/assignment3.pdf
Binary file not shown.
Binary file added MTH208/Assignments/assignment4.pdf
Binary file not shown.
Binary file added MTH208/Assignments/assignment5.pdf
Binary file not shown.
Binary file added MTH208/Assignments/assignment6.pdf
Binary file not shown.
Binary file added MTH208/Assignments/assignment7.pdf
Binary file not shown.
27 changes: 27 additions & 0 deletions MTH208/EndSem/Cans2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <Rcpp.h>
using namespace Rcpp;


// [[Rcpp::export]]
NumericVector sumsC(NumericMatrix x, int s)
{
// Declaring the output vector
NumericVector colSum(s);

// Filling the output vector with zeros
for (int i = 0; i < s; i++)
{
colSum[i] = 0;
}

// Calculating the column sums
for (int i = 0; i < x.nrow(); i++)
{
for (int j = 0; j < s; j++)
{
colSum[j] = colSum[j] + x(i, j);
}
}

return colSum;
}
1 change: 1 addition & 0 deletions MTH208/EndSem/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Answers are of a student, not the professor's.
20 changes: 20 additions & 0 deletions MTH208/EndSem/ans1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
autoreg_fast <- function(n, rho)
{
# Allocating space to the out vector beforehand
out <- numeric(length = n)

# A slight improvement was observed when calculating
# the random values at once
errors <- rnorm(n - 1)

# Doing the required calculations
out[1] <- 0
for(t in 2:n)
{
error <- errors[t-1]
error <- rho*out[t-1] + error
out[t] <- error
}

return(out)
}
14 changes: 14 additions & 0 deletions MTH208/EndSem/ans2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
library(Rcpp)

sourceCpp(file = "Cans2.cpp")

sel_sums <- function(mat){
# Obtaining the size of the square matrix
p = dim(mat)[1]

# Randomly choosing a number s between 1 and p (inclusive)
s = sample(1:p, size = 1)

# Calling the sourced C++ function
return(sumsC(mat, s))
}
21 changes: 21 additions & 0 deletions MTH208/EndSem/ans3.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("ques3.Rdata")

# Size of the square matrix
p <- dim(mat)[1]

# Eigenvalues of the matrix
eigen.values <- eigen(mat, only.values = TRUE)$values

# Declaring the log of the answer
log.ans <- 0

# Adding sum terms obtained on logarithm
log.ans <- log.ans + (p * log(2.7)) - (p * log(p)) + sum(log(1:p))

# Adding the logarithm of the determinant term
log.ans <- log.ans + ((1/p) * sum(log(eigen.values)))

# Adding (effectively subtracting) the logarithm of the trace term
log.ans <- log.ans - log(sum(eigen.values))

ans <- exp(log.ans)
26 changes: 26 additions & 0 deletions MTH208/EndSem/ans4.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
library(MASS)
library(tidyverse)

# Calculating incidents per year of every ship
dat <- ships %>%
select(type, service, incidents) %>%
filter(service != 0) %>%
mutate(`Incidents per Year` = (incidents / (service / 12)))

# Creating boxplot of Incidents per year v/s Type of Ship
plt <- ggplot(dat) +
geom_boxplot(
aes(x = type, y = `Incidents per Year`)
) +
labs(
title = "Incidents per Year of different types of Ships"
) +
xlab("Type of Ship")

## This plot disproves the hypothesis.
## The ships of type B were also used for most
## number of months which had led to most number
## of accidents. Ship type E had the most number
## incidents per year.

plt
Binary file added MTH208/EndSem/endsem.pdf
Binary file not shown.
Binary file added MTH208/EndSem/ques3.Rdata
Binary file not shown.
1 change: 1 addition & 0 deletions MTH208/MidSem/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Answers are of a student, not the professor's.
22 changes: 22 additions & 0 deletions MTH208/MidSem/ans1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 'n' is the number of people in the room
# The function returns TRUE when 2 people share the same birthday
birthday <- function (n){
# Getting the random birthdays of people in the room
bdates <- sample(1:365, size = n, replace = TRUE)

# Taking a vector containing unique birthdays
uniq_dates <- unique(bdates)

# Checking whether all birthdays are unique or not
if (length(bdates) != length(uniq_dates)){
return(TRUE)
} else {
return(FALSE)
}
}

outcomes25 <- replicate(1000, birthday(25))
ans25 <- length(outcomes25[outcomes25]) / 1000

outcomes50 <- replicate(1000, birthday(50))
ans50 <- length(outcomes50[outcomes50]) / 1000
24 changes: 24 additions & 0 deletions MTH208/MidSem/ans2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
library(imager)

# An imager image is taken as input
flip <- function (img){
# Convert the image pixel and color values into an array
orig.img.arr <- as.array(img[, , 1, ])

# Create an empty array to contain values of new image
new.img.arr <- array(0, dim = dim(orig.img.arr))

# The following loop fills the new image array
img.dims <- dim(orig.img.arr)
for (i in 1:img.dims[1]){
for (j in 1:img.dims[2]){
for (k in 1:img.dims[3]){
new.img.arr[i, j, k] <- orig.img.arr[img.dims[1] + 1 - i, j, k]
}
}
}

# Create an imager image from the array and return it
new.img <- as.cimg(new.img.arr)
return(new.img)
}
19 changes: 19 additions & 0 deletions MTH208/MidSem/ans3.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
library(tibble)
library(tidyverse)

# Read the titanic data from the csv file
titanic.data <- as_tibble(read_csv("titanic.csv"))

# Convert the Survived column into a factor having the values "Died" and "Survived"
titanic.data$Survived <- factor(titanic.data$Survived)
levels(titanic.data$Survived) <- c("Died", "Survived")

# The final graph
finalP <- ggplot(titanic.data, aes(x = Survived, y = Fare)) +
geom_boxplot(aes(color = Sex)) +
labs(title = "Fare vs Survival",
subtitle = "Irrespective of Sex, richer people survived",
x = "",
y = "Fare"
) +
coord_flip()
Binary file added MTH208/MidSem/boat.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MTH208/MidSem/midsem.pdf
Binary file not shown.
Loading