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) |
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) |
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(reshape2) | |
library(ggplot2) | |
theme_dotdiagram <- function(...){ | |
theme_minimal(...)%+% | |
theme(axis.text.y = element_text(colour="black"), | |
axis.ticks = element_blank(), | |
axis.text.x = element_blank(), | |
axis.title.x = element_blank(), | |
panel.grid.minor = element_blank(), |
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(dplyr) | |
library(ggplot2) | |
x <- c("ward.D","ward.D2", "single","complete", | |
"average","mcquitty","median","centroid") | |
X <- log(as.matrix(iris[,1:2])) | |
df <- data.frame(X) | |
d <- dist(X) |
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(dplyr) | |
library(ggplot2) | |
x <- c("ward.D","ward.D2", "single","complete", | |
"average","mcquitty","median","centroid") | |
X <- log(as.matrix(iris[,1:4])) | |
d <- dist(X) | |
dm <- as.matrix(d) |
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[tikz,border=14pt]{standalone} | |
\usepackage{tikz} | |
\usetikzlibrary{matrix,shapes,decorations.pathreplacing, backgrounds, positioning} | |
\begin{document} | |
\begin{tikzpicture}[ | |
%Styles | |
Matrix/.style={ | |
matrix of nodes, | |
text height=2.5ex, |
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(pheatmap) | |
library(grid) | |
mid0scale <- function(test, paletteLength=120){ | |
myColor <- colorRampPalette(c("orange", "white", "royalblue"))(paletteLength) | |
myBreaks <- c(seq(min(test), 0, length.out=ceiling(paletteLength/2) + 1), | |
seq(max(test)/paletteLength, max(test), length.out=floor(paletteLength/2))) | |
return(list(color=myColor, breaks=myBreaks)) | |
} | |
set.seed(123) |