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
library(tidyverse) | |
library(ggvis) | |
## this column needs to be unique for each row (primary key)! | |
mtcars$url <- paste0("https://en.wikipedia.org/wiki/", 1:nrow(mtcars)) | |
mtcars %>% | |
ggvis(~mpg, ~hp) %>% | |
layer_points(size := 50, size.hover := 200, | |
fillOpacity := 0.4, fillOpacity.hover := 0.7, |
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
# pitch/play data scraped with pitchRx | |
pitches18 %>% | |
filter(type == 'X', | |
pitch_type == "FF") %>% | |
mutate(TB = case_when( | |
event == "Single" ~ 1, | |
event == "Double" ~ 2, | |
event == "Triple" ~ 3, | |
event == "Home Run" ~ 4, |
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
git clone https://github.com/jeetsukumaran/Syrupy | |
cd Syrupy | |
python setup.py install | |
syrupy.py -m 20 |
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
strapz <- list() | |
k <- 10 | |
for (i in 1:k){ | |
meps.bs <- meps %>% sample_n(nrow(.), replace = TRUE) | |
prop.score.fit <- multinom(race ~ . - healthExp, data = meps.bs, maxit = 200, | |
trace = FALSE, model = TRUE) | |
strapz[[i]] <- prop.score.fit | |
} | |
save(strapz, file = "strapz.Rdata") |
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
library(expm) | |
###### polynomial ###### | |
p <- 4 | |
mt <- rep(1, p) | |
G <- diag(p); G[1:(p-1), 2:p] <- G[1:(p-1), 2:p] + diag(p-1); | |
F <- c(1, rep(0, p-1)) | |
print(G); print(mt); print(F) |
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
library(expm) | |
p <- 4 | |
mt <- rep(1, p) | |
G <- diag(p); G[1:(p-1), 2:p] <- G[1:(p-1), 2:p] + diag(p-1); | |
F <- c(1, rep(0, p-1)) | |
print(G); print(mt); print(F) | |
k <- 5 | |
G %^% k |
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
library(tidyverse) | |
phis <- c(0.6, -0.4, 0.2, 0.2, 0.1) | |
p <- length(phis) | |
X <- rnorm(p) | |
G <- rbind(phis, | |
cbind(diag(p-1), | |
rep(0, p-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
figure(4); clf | |
subplot(2,1,1) | |
h=sqrt(squeeze(sC(itrend,itrend,:)))'.*sq; ciplot(sm(itrend,:)-h,sm(itrend,:)+h,1:T,[.85 .85 .85]); hold on | |
plot(1:T,sm(itrend,:),'b-'); eval(xa); hold off | |
title('90% smoothed posterior intervals for trend trend '); ylabel('Parameter') |
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 build_hash_table(C, d, k, data): | |
vals = np.arange(C*d) | |
HT = defaultdict(set) | |
HTR = defaultdict(set) | |
I = np.random.choice(vals, k, replace = False) # figure out if replace = True or False | |
for j in range(n): | |
# for every point, generate hashed point and sample k bits | |
p = data[j] | |
hashed_point = lsh_hash(p, C)[I] |
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
a = 3 | |
b = 4 | |
sigma = 2 | |
1 - pnorm((a-b)/sigma) | |
pnorm((b-a)/sigma) |
NewerOlder