View 黑白网页.html
<!-- 在网页的 head 部分加入以下内容,可以将网页改为黑白悼念模式 --> | |
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> | |
<style type="text/css"> | |
html { | |
filter: grayscale(100%); | |
-webkit-filter: grayscale(100%); | |
-moz-filter: grayscale(100%); | |
-ms-filter: grayscale(100%); | |
-o-filter: grayscale(100%); | |
filter: url(data:image/svg+xml;utf8,;#grayscale); |
View Sumatra.edt
// Sumatra? | |
FindInString(`%$('AcroRead')`,'SumatraPDF',1,2,1000,1); | |
IfOK(!"Relax;",!"JMP('not_sumatra')"); | |
Run('%$("AcroRead"); -reuse-instance -inverse-search "\"%B\WinEdt.exe\" \"[Open(|%%f|);SelPar(%%l,8);]\"" "%P\%N.pdf"','%P',0,0,'%N.pdf - SumatraPDF',1,1); | |
DDEOpen('',"SUMATRA","control",1); | |
// send a DDE command to perform forward-search | |
// the format of the DDE command is [ForwardSearch("<pdffilepath>","<sourcefilepath>",<line>,<column>[,<newwindow>, <setfocus>])] | |
// if newwindow = 1 then a new window is created even if the file is already open | |
// if focus = 1 then the focus is set to the window |
View updown_colors.R
updown_colors <- function(n = 50, down.col = 1/3, up.col=1, saturation = 1) | |
{ | |
c(hsv(down.col, saturation, seq(1,0,length=n)), hsv(up.col, saturation, seq(0,1,length=n))) | |
} |
View normal_test.R
# one sample normal test | |
norm_test1 <- function(x.n, x.mu, x.var, mu, side=0) | |
{ | |
nu <- x.n - 1 | |
z <- (x.mu - mu) / sqrt(x.var / x.n) | |
p <- p.value(pnorm, z, side=side) | |
data.frame(mean=x.mu, df=nu, statistic=z, p.value=p) | |
} | |
# two samples normal test |
View t_test.R
# one sample t-test | |
t_test1 <- function(x.n, x.mu, x.var, mu, side=0) | |
{ | |
nu <- x.n - 1 | |
t <- (x.mu - mu) / sqrt(x.var / x.n) | |
p <- p.value(pt, t, params=nu, side=side) | |
data.frame(mean=x.mu, df=nu, statistic=t, p.value=p) | |
} | |
# two samples t-test |
View p_value.R
p_value <- function(cdf, z, params=numeric(0), side=0) | |
{ | |
n <- length(params) | |
p <- switch(n+1, | |
cdf(z), | |
cdf(z, params), | |
cdf(z, params[1], params[2]), | |
cdf(z, params[1], params[2], params[3]) | |
) | |
if (side < 0) p |
View fold_change.R
fold_change <- function(x, y, confidence.level=90, var.equal=F) | |
{ | |
fc.interval(length(x), mean(x), var(x), length(y), mean(y), var(y), confidence.level, var.equal) | |
} | |
fc.interval <- function(x.n, x.mu, x.var, y.n, y.mu, y.var, confidence.level=90, var.equal=F) | |
{ | |
mu <- x.mu - y.mu | |
if (var.equal) { | |
nu <- x.n + y.n - 2 |
View robust_fold_change.R
robust_fold_change <- function(case, control) | |
{ | |
m <- dim(case)[2] | |
n <- dim(control)[2] | |
fc.raw <- matrix(nrow=dim(case)[1], ncol=m*n) | |
for (i in 1:m) { | |
for (j in 1:n) { | |
fc.raw[, (i-1)*m+j] <- case[,i] - control[,j] | |
} | |
} |
View merge_rows.R
merge_rows <- function(x, method=mean, na.rm=FALSE) | |
{ | |
x <- as.matrix(x[!is.na(rownames(x)), ]) | |
r <- unique(rownames(x)) | |
m <- length(r) | |
if (dim(x)[1] != m) { | |
y <- matrix(nrow=m, ncol=dim(x)[2]) | |
rownames(y) <- r | |
colnames(y) <- colnames(x) | |
for (i in 1:m) { |
View diffusion_kernel.R
diffusion_kernel <- function(adj, beta = 1) | |
{ | |
lap <- adj - diag(rowSums(adj)) | |
eig <- eigen(lap) | |
dif <- eig$vectors %*% diag(exp(beta * eig$values)) %*% t(eig$vectors) | |
dif | |
} |