Skip to content

Instantly share code, notes, and snippets.


John Myles White johnmyleswhite

View GitHub Profile
View stats_woes.txt
"We are struck by the fact that in the social and behavioral sciences,
epidemiology, economics, market research, engineering, and even applied
physics, statistical methods are routinely used to justify causal inferences
from data not obtained from randomized experiments, and sample statistics are
used to predict the effects of policies, manipulations or experiments. Without
these uses the profession of statistics would be a far smaller business. It may
not strike many professional statisticians as particularly odd that the
discipline thriving from such uses assures its audience that they are
unwarranted, but it strikes us as very odd indeed."
johnmyleswhite /
Last active Aug 29, 2015
Counterexamples in Statistics

The sample mean is never exactly equal to the true mean when the true mean is irrational

Let D be any distribution over the integers. Suppose that the first moment exists for D and is an irrational number.

In this case, the sample mean is never exactly equal to the true mean because the sample mean is always a rational number.

This is simple to prove: the sample mean is always a sum of integers divided by the number of samples, which is always an integer.

johnmyleswhite / mutate.R
Created Feb 3, 2014
Scope reification in R
View mutate.R
foo <- function(frame_number)
assign("frame_number", -1, envir = sys.frame(frame_number))
bar <- function()
frame_number <- sys.nframe()
View ftw.R
a <- 1
b <- 2
ftw <- function()
vars <- ls(envir = .GlobalEnv)
rm(list = vars, envir = .GlobalEnv)
johnmyleswhite /
Created Feb 11, 2014
Abstract for UC Davis Talk

Julia and Statistical Computing

Julia is a new language for technical computing. The language is designed to solve the "two language problem", in which scientists prototype code in a higher-level language like R and then rewrite parts (or all) of their code in a lower-level language like C. Julia strives to expose a set of basic abstractions that allow programmers to transition easily between quick-and-dirty prototype code and production-quality code.

johnmyleswhite / rsa.jl
Created Mar 2, 2014
Toy RSA implementation in Julia based on Matt Might's implementation in Scheme
View rsa.jl
# ---
# Author: Matthew Might
# Translator: John Myles White
# Site:
# ---
# ---
# Mathematical routines
# ---
johnmyleswhite / poissonmf.jl
Last active Aug 29, 2015
Poisson matrix factorization: a naive implementation using dense arrays
View poissonmf.jl
using Distributions
const Ψ = digamma
function generate(
johnmyleswhite /
Last active Aug 29, 2015
Bernoulli matrix factorization


Attempt to factor a binary matrix, $D$, under the assumption that entries are IID Bernoulli draws, conditional on the value of a link-transformed linear predictor, $\mathbb{E}[D_{i, j}] = I(\mu + a_i + b_j + X_{i}^{T} Y_{j})$, where $I$ is the inverse logit link function.

Because of non-identifiability problems, we use a consistent $\mathcal{N}(0, \sigma^2)$ prior over all parameters in the model

johnmyleswhite / 01-bitdiddle.jl
Last active Aug 29, 2015
Function Evaluation in Julia and R: Example 1.5 from SICP
View 01-bitdiddle.jl
# Ben Bitdiddle's demonstration that Julia uses applicative-order evaluation
p() = p()
# p (generic function with 1 method)
test(x, y) = x == 0 ? 0 : y
# test (generic function with 1 method)
johnmyleswhite / factor_mult.R
Last active Aug 29, 2015
Factor arithmetic
View factor_mult.R
> x <- 1
> f <- factor(x)
> f[1] * f[1]
[1] NA
Warning message:
In Ops.factor(f[1], f[1]) : * not meaningful for factors
> p <- f[1] * f[1]
Warning message:
In Ops.factor(f[1], f[1]) : * not meaningful for factors
> class(p)