This file contains hidden or 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
| def isPalindrome(a,b): | |
| s = str(a*b) | |
| if s == s[::-1]: | |
| return True | |
| palinlist = [] | |
| for i in range(999, 101, -1): | |
| for j in range(999, 101, -1): | |
| num = i*j | |
| if isPalindrome(i,j): |
This file contains hidden or 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
| pkg load statistics | |
| data = load('vlss.txt'); | |
| y = data(:,4); | |
| n= length(y); | |
| logtexp = data(:,3); | |
| X = [ones(n,1) logtexp]; | |
| beta = inv(X'*X)*X'*y; %Beta coefficients | |
| yhat = X*beta; | |
| e = y - yhat; | |
| k = size(X,2); |
This file contains hidden or 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
| N= 5000; | |
| n = 2; | |
| lambda = 1; | |
| mu = 3; | |
| p = ones([n,1]); | |
| x = zeros(n,1); | |
| e = zeros(n,1); | |
| y = zeros(n,1); | |
| for i =1:N; | |
| x(:,i) = exprnd(lambda,n,1); |
This file contains hidden or 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 = load('carsdata2.txt'); | |
| y = data(:, 1)/1000; | |
| n = length(y); % Number of observations | |
| predvar = data(:, 2:8); % Features | |
| Reliability = predvar(:,1); | |
| OwnerSat = predvar(:,2); | |
| RoadScore = predvar(:, 3); | |
| MPG = predvar(:, 4); | |
| Zeroto60 = predvar(:,5); | |
| NotReliable = (Reliability==4|Reliability==5); |
This file contains hidden or 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
| delta0 <- c(0,0,0,0) | |
| xbar1 <- (c(2.287, 12.600, 0.347, 14.830)) | |
| xbar2 <- (c(2.404, 7.155, 0.524, 12.840)) | |
| S1 <- matrix(c(.459, .254, -.026, -.244, .254, 27.465, -.589, -.267, -.206, -.589, .030, .102, -.244, -.267, .102, 6.854), nc=4) | |
| S2 <- matrix(c(.944, -.089, .002, -.719, -.089, 16.432, -.400, 19.044, .002, -.400, .024, -.094, -.719, 19.044, -.094, 61.854), nc =4) | |
| n1 <- n2 <- 20 | |
| p <- length(delta0) | |
| alpha <- 0.05 | |
| Spooled <- ((n1-1)*S1 + (n2-1)*S2 )/(n1+n2-2) | |
| T2 <- (1/n1+1/n2)^{-1}*t(xbar1- xbar2 - delta0)%*%solve(Spooled)%*%(xbar1 - xbar2) |
This file contains hidden or 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
| S0 = 100.0; | |
| X = 110.0; | |
| H = 85.0; | |
| R = 1; | |
| sigma = 0.25; | |
| r = 0.05; | |
| T = 1.0; | |
| M = 100; | |
| dt=T/M; % Time step | |
| mudt=(r-0.5*sigma^2)*dt; |
This file contains hidden or 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
| data1 <-read.table("C:/Users/DASA0/Desktop/Stat 524/wichern data/T6-5.dat", sep="") | |
| data2 <-read.table("C:/Users/DASA0/Desktop/Stat 524/wichern data/T6-6.dat", sep="") | |
| data1 <- as.data.frame(data1) | |
| data2 <- as.data.frame(data2) | |
| xbar1 <- apply(data1, 2, mean) | |
| xbar2 <- apply(data2, 2, mean) | |
| t <- c(0, 1, 2, 3) | |
| df <- data.frame(x=t, y=xbar1, type='Profile 1') | |
| df <- rbind(df, data.frame(x=t, y=xbar2, type='Profile 2')) |
This file contains hidden or 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
| numberparity <- read.csv("C:/Users/DASA0/Desktop/Stat 524/numberparity.csv", sep=",") | |
| numberparity <- as.matrix(numberparity) | |
| C <- matrix(c(-1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1), nc=4) | |
| datanew <- numberparity%*%t(C) | |
| onesampletest<- function(data=data, mu0=mu0, alpha=alpha){ | |
| #computing Hotelling's T-square and the critical value | |
| xbar <- apply(data, 2, mean) | |
| S <- cov(data) | |
This file contains hidden or 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
| delta0 <- c(0,0) | |
| xbar1 <- (c(204.4, 556.6)) | |
| xbar2 <- (c(130.0, 355.0)) | |
| S1 <- matrix(c(13825.3, 23823.4, 23823.4, 73107.4), nc=2) | |
| S2 <- matrix(c(8632.0, 19616.7, 19616.7, 55964.5), nc=2) | |
| n1 <- 45 | |
| n2 <- 55 | |
| p <- 2 | |
| alpha <- 0.05 | |
| Spooled <- ((n1-1)*S1 + (n2-1)*S2 )/(n1+n2-2) |
This file contains hidden or 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
| perspdata <- read.csv("C:/Users/DASA0/Desktop/Stat 524/Perspiration.csv", sep=",") | |
| perspdata <- as.data.frame(perspdata) | |
| names(perspdata) <- c("Sweat Rate", "Sodium", "Potassium") | |
| xbar <- sapply(perspdata, mean) #calculate mean for each variable | |
| x1 <- perspdata[,1, drop=TRUE] | |
| x2 <- perspdata[,2, drop=TRUE] | |
| x3 <- perspdata[,3, drop=TRUE] |