Skip to content

Instantly share code, notes, and snippets.

View even4void's full-sized avatar

chl even4void

View GitHub Profile
@even4void
even4void / power.R
Created August 11, 2011 10:05
A simple animated demonstration of Power Analysis
mha <- 1 # mean under the alternative
es <- 2 # observed effect (deviation from mean under H0)
x <- seq(-6, 6, length=1000)
dh0 <- dnorm(x, 0, 1)
show.it <- function(es, mha, verbose=FALSE) {
dh1 <- dnorm(x, mha, 1)
plot.new()
plot.window(xlim=range(x), ylim=c(0,.6))
@even4void
even4void / make_package.R
Last active June 1, 2022 13:03
ROCAD analysis
# Time-stamp: <2010-04-05 17:11:20 chl>
#
# Automaticaly collate R file and try to build a package with
# documentation generated by Roxygen.
#
require(roxygen)
rm(list=ls())
package.skeleton('rocad',code_files=c('rocad.R','rocad-package.R'),force=T)
roxygenize('rocad',roxygen.dir='rocad',copy.package=F,unlink.target=F)
try(system("R CMD build rocad"))
https://github.com/eliben/4clojure-solutions.git
https://github.com/bcc32/99.git
https://github.com/politrons/Dive_into_Haskell.git
https://github.com/hbctraining/Intro-to-R.git
https://github.com/ppham27/MLaPP-solutions.git
https://github.com/ArthurZC23/Machine-Learning-A-Probabilistic-Perspective-Solutions.git
https://github.com/nayuki/Nayuki-web-published-code.git
https://github.com/davidemms/OrthoFinder.git
https://github.com/ctgk/PRML.git
https://github.com/wentaocn/Programming-in-Haskell.git
@even4void
even4void / pdf2img.sh
Created January 11, 2022 17:29
Convert page from a PDF to a PNG
#!/usr/bin/env bash
# Note: pdftoppm has page range so the first line is probably not necessary.
f="/tmp/tmp.$RANDOM"
pdftk "$1" cat $2 output $f
pdfcrop $f $f.crop
pdftoppm -png -rx 300 -ry 300 $f.crop $HOME/"$1".png
rm $f $f.crop
@even4void
even4void / fasview.py
Created January 7, 2022 19:31
Fast Fasta TUI viewer
#!/usr/bin/env python3
import os
import statistics
import sys
from Bio import SeqIO
term_width = os.get_terminal_size().columns
term_height = os.get_terminal_size().lines
id_width = 15
@even4void
even4void / org-babel.el
Created December 20, 2021 08:29
org-babel
;;; org-babel.el --- default settings for org->pdf compilation
;;;
;;; Commentary:
;;; This is very basic stuff.
;;;
;;; Code:
(require 'org)
(add-to-list 'load-path "/home/chl/Documents/notes")
(require 'ox-bibtex)
library(mixOmics)
library(RColorbrewer)
X <- replicate(6, rnorm(50))
X.row.mds <- cmdscale(dist(X), k=1)
X.col.mds <- cmdscale(dist(t(X)), k=1)
cim(cor(X)[order(X.col.mds),order(X.col.mds)], col=rev(brewer.pal(8, "RdBu")))
cim(cor(t(X))[order(X.row.mds),order(X.row.mds)], col=rev(brewer.pal(8, "RdBu")))
cim(X, col=rev(brewer.pal(8, "RdBu"))
@even4void
even4void / CVJC.bib
Created March 10, 2011 19:38
Articles proposed for CrossValidated Journal Club
@article{arlot2010survey,
Author = {Arlot, S. and Celisse, A.},
Journal = {Statistics Surveys},
Pages = {40--79},
Title = {A survey of cross-validation procedures for model selection},
Volume = {4},
Year = {2010}}
@article{feinerer2008text,
Author = {Feinerer, I. and Hornik, K. and Meyer, D.},
@even4void
even4void / venn_sql.r
Created January 7, 2011 11:58
Toy illustration of SQL joins with Venn diagrams in R
# Time-stamp: <2011-01-07 12:41:47 chl>
#
# Some illustrations of SQL joins with R.
# Inspiration: Jeff Atwood, http://bit.ly/eMhJEp
#
tableA <- data.frame(id=1:4, name=c("Pirate","Monkey","Ninja","Spaghetti"))
tableB <- data.frame(id=1:4, name=c("Rutabaga","Pirate","Darth Vader","Ninja"))
@even4void
even4void / reliability.R
Created October 17, 2010 19:36
Some illustrations of reliability analysis.
# Some illustrations of reliability analysis.
# Time-stamp: <2010-10-17 21:35:51 chl>
x <- c(12,8,22,10,10,6,8,4,14,6,2,22,12,7,24,14,8,4,5,6,14,5,5,16)
GHQ <- data.frame(subject=gl(12,1,24), time=gl(2,12), score=x)
# ----------------------------------------------------
# Computing reliability (Rx) by hand from ANOVA tables
# ----------------------------------------------------
# one-way ANOVA (assuming no time trends)
summary(aov(score ~ subject, data=GHQ))