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
<?xml version="1.0" encoding="utf-8" ?> | |
- <colorTheme id="1234" name="new" modified="2011-02-01 01:56:53" author="Bob Forrest" website="anythingbutrbitrary.blogspot.com"> | |
<occurrenceIndication color="#616161" /> | |
<findScope color="#191919" /> | |
<deletionIndication color="#FF0000" /> | |
<singleLineComment color="#D6D6D6" /> | |
<multiLineComment color="#666666" /> | |
<commentTaskTag color="#666666" /> | |
<javadoc color="#666666" /> | |
<javadocLink color="#666666" /> |
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
rm(list = ls()) | |
# Setup: 3 subjects, 5 total measurements, one covariate | |
df <- data.frame(x1 = c(1,5,2,3,4), subject = c(1,2,3,1,2)) | |
df$subject <- factor(df$subject) | |
n <- 5 | |
beta <- matrix(c(1.3, 2), ncol=1) # coeffient for x1, a value of 2 | |
u <- matrix(c(-.5, .6, 1.5), ncol=1) # the three random effects for subjects |
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
rm(list = ls()) | |
library(qcc) | |
dat <- data.frame(name = c("Toy Story", "A Bug's Life", "Toy Story 2", | |
"Monsters Inc", "Nemo", "Incredibles", | |
"Cars", "Ratatouille", "Wall-E", "Up", "Toy Story 3", | |
"Cars 2", "Brave", "Monsters U"), | |
x = c(76, 77, 161, 185, 235, 224, 143, 213, 228, 273, 261, 79, 169, 137 ), | |
n = c(76, 84, 161, 193, 237, 231, 194, 222, 237, 278, 264, 203, 217, 175) | |
) |
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
N <- 10000 | |
x <- rnorm(N) | |
y <- exp(-.75 + 1.2*x) + rnorm(N) | |
alpha <- -.5 | |
beta <- 1 | |
for ( i in 1:10) { # 10 iterations, for no particular reason | |
X <- cbind(exp(alpha + beta*x), x*exp(alpha + beta*x)) | |
pred <- exp(alpha + beta*x) | |
diff.soln <- solve(t(X) %*% X) %*% t(X) %*% (y - pred) |
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
# Open two python shells | |
# Shell 1 will be our server, Shell 2 will be our client | |
##### In Shell 1 ##### | |
import socket | |
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
server_socket.bind(("127.0.0.1", 5000)) | |
server_socket.listen(5) # Max 5 connect requests in queue |
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
library(lme4) | |
head(Pastes) | |
# three casks are nested within each of 10 batches. | |
# No cask is used twice! (30 total casks) | |
# Noted that the variable "sample" is a concatination of "batch" and "cask" | |
lmer1 <- lmer(strength ~ 1 + (1 | batch) + (1 | sample), Pastes, REML=F) | |
lmer2 <- lmer(strength ~ 1 + (1 | batch) + (1 | batch:cask), Pastes, REML=F) | |
lmer3 <- lmer(strength ~ 1 + (1 | batch/cask), Pastes, REML = F) | |
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
convolve_training <- function(training, n, tau) { | |
sum(training[1:(n - 1)] * exp_decay((n - 1):1, tau)) | |
} | |
fitness <- sapply(1:nrow(train_df), | |
function(n) convolve_training(train_df$w, n, 60)) | |
fatigue <- sapply(1:nrow(train_df), | |
function(n) convolve_training(train_df$w, n, 13)) |
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
# Recover parameters using non-linear regression | |
rss <- function(theta) { | |
int <- theta[1] # performance baseline | |
k1 <- theta[2] # fitness weight | |
k2 <- theta[3] # fatigue weight | |
tau1 <- theta[4] # fitness decay | |
tau2 <- theta[5] # fatigue decay | |
fitness <- sapply(1:nrow(train_df), | |
function(n) convolve_training(train_df$w, n, tau1)) |
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
train_df <- data.frame(day = 1:259, day_of_week = 0:258 %% 7) | |
train_df$period <- ifelse(train_df$day <= 147, "build-up", "competition") | |
train_df$w <- with(train_df, w <- | |
-24 * (day_of_week == 0) + | |
12 * (day_of_week == 1) + | |
8 * (day_of_week == 2) + | |
0 * (day_of_week == 3) + | |
6 * (day_of_week == 4) + | |
-8 * (day_of_week == 5) + | |
6 * (day_of_week == 6)) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer