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(ggplot2) | |
out <- vector("list", 10000) | |
for(i in 1:10000){ | |
x <- rt(10,3) | |
out[[i]] <- sign(x)*rank(abs(x)) | |
} | |
ggplot(data=NULL)+ |
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
signTable <- function(mu,x){ | |
x2 <- x-mu | |
x2 <- x2[x2 != 0] | |
data.frame(table(sign(x2)), loc=mu) | |
} | |
wilcoxTable <- function(mu,x){ | |
x2 <- x-mu | |
x2 <- x2[x2 != 0] | |
data.frame(w=sign(x2)*rank(abs(x2)), loc=mu) |
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(ggplot2) | |
binomfun <- function(c,n){ | |
sum(choose(n,floor(n/2+seq(-c,c)))/(2^n)) | |
} | |
wilcoxCI <- function(x,level){ | |
xx <- outer(x,x,"+") | |
u <- sort(xx[lower.tri(xx, diag = TRUE)]/2) | |
n <- length(u) |
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(ggplot2) | |
#check the moments | |
integrate(function(x)x*dexp(x), 0,Inf) | |
integrate(function(x)x^2*dexp(x), 0,Inf) | |
integrate(function(x)x*dnorm(x,1,1), -Inf,Inf) | |
integrate(function(x)x^2*dnorm(x,1,1), -Inf,Inf) | |
pv_simfun <- function(n1,n2){ | |
x1 <- rexp(n1) |
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
binomfun <- function(c,n){ | |
sum(choose(n,n/2+seq(-c,c))/(2^n)) | |
} | |
signCI <- function(x,level){ | |
n <- length(x) | |
sx <- sort(x) | |
alpha_c = sapply(1:(n/2), binomfun, n=n) | |
k <- which.max(alpha_c-(level)>0) | |
lower <- sx[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(rvest) | |
library(dplyr) | |
#browseURL(paste0(url_ncbi,qt)) | |
qt <- "ID3" #searh query | |
NCBI_search <- function(qt){ | |
url_ncbi <- "https://www.ncbi.nlm.nih.gov/gene/?term=" | |
url_t <- paste0(url_ncbi,qt) | |
html_t <- read_html(url_t) |
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(ggplot2) | |
library(dplyr) | |
library(numDeriv) | |
lp <- function(x,mu,u){ | |
-exp(u)*sum((x-mu)^2)/2 + length(x)*u | |
} | |
dlp_mu <- function(x,mu,u){ | |
exp(u)*sum((x-mu)) | |
} |
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
\documentclass[dvipdfmx, dvipsnames]{beamer} | |
\usepackage{tikz} | |
\usetikzlibrary{matrix,shapes, decorations.pathreplacing, backgrounds, positioning} | |
\begin{document} | |
\frame{ | |
\begin{figure} | |
\begin{tabular}{ccc} | |
inner product of \Huge $($ | |
\begin{tikzpicture} |
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
drawfive <- function(iter){ | |
three = 0L | |
four = 0L | |
onepair = 0L | |
twopair = 0L | |
fullhouse = 0L | |
straight = 0L | |
flush = 0L | |
#iter <- 100000 | |
dec <- expand.grid(suit=1L:4L,rank=1L:13L) |
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
## | |
p_stat_t <- function(v, df = 1, | |
alternative = "two.sided"){ | |
if (!alternative %in% c("two.sided", "less", "greater")) { | |
stop("alternative must be either \"two.sided\", \"less\", or \"greater\".") | |
} | |
if(alternative == "two.sided"){ | |
p0 <- 2*pt(abs(v), df, lower.tail = FALSE) | |
}else if(alternative == "less"){ | |
p0 <- pt(v, df) |