This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f <- function(toss=1){ | |
x <- sample(1:2, size=toss, replace=TRUE) | |
y <- sample(1:2, size=toss, replace=TRUE) | |
return(cbind(x,y)) | |
} | |
set.seed(2500) | |
toss_times <- as.data.frame(f(2000)) | |
library(plyr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Splitting the data set into train and test | |
set.seed(2) | |
part <- sample(2, nrow(data), replace = TRUE, prob = c(0.7, 0.3)) | |
train<- data[part == 1,] | |
test<- data[part == 2,] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("glmnet") | |
library(glmnet) | |
train$Item_Weight[is.na(train$Item_Weight)] <- mean(train$Item_Weight, na.rm = TRUE) | |
train$Outlet_Size[is.na(train$Outlet_Size)] <- "Small" | |
train$Item_Visibility[train$Item_Visibility == 0] <- mean(train$Item_Visibility) | |
train$Outlet_Establishment_Year=2013 - train$Outlet_Establishment_Year | |
train<-train[c(-1)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Calculating eigenvalues and eigenvectors | |
A<-matrix(c(30,31,40,41,50,51,60,61,70),nrow = 3,byrow = T) | |
e <- eigen(A) | |
e$values | |
e$vectors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Inverse of matrix | |
B<-matrix(c(30,31,40,41,50,51,60,61,70),nrow = 3,byrow = T) | |
A<-solve(B) | |
A | |
#Determinant of A | |
det(A) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Multiplication of matrix | |
A<-matrix(c(11,12,13,14,15,16,17,18,19),nrow = 3,byrow = T) | |
B<-matrix(c(20,21,22,23,24,25,26,27,28),nrow = 3,byrow = T) | |
A*B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Transpose of a matrix | |
t(A) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A<-matrix(c(11,12,13,14,15,16,17,18,19),nrow = 3,byrow = T) | |
A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data <- read.csv(file.choose()) | |
#POPULATION PARAMETERS | |
pop_sd <- sd(data$Screen_size.in.cm.)*sqrt((length(data$Screen_size.in.cm.)-1)/(length(data$Screen_size.in.cm.))) | |
pop_mean <- mean(data$Screen_size.in.cm.) | |
z <- (9.5 - pop_mean) / pop_sd | |
z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pnorm(80, mean=67, sd=13.7, lower.tail=FALSE) |
NewerOlder