This file contains 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
using Distributions | |
using PyPlot | |
ϵ = 0.0001 | |
n_grid = 10_000 | |
ps = linspace(ϵ, 1 - ϵ, n_grid) | |
ss = [std(Bernoulli(p)) for p in ps] | |
sks = [skewness(Bernoulli(p)) for p in ps] |
This file contains 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
using Distributions | |
using HypothesisTests | |
n_sims = 1_000_000 | |
n = 2 | |
x = Array{Float64}(n) | |
y = Array{Float64}(n) | |
p_d = Array{Float64}(n_sims) | |
for s in 1:n_sims | |
for i in 1:n |
This file contains 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
using Distributions | |
using HypothesisTests | |
n_sims = 1_000_000 | |
n = 20 | |
x = Array{Float64}(n) | |
y = Array{Float64}(n) | |
p_d = Array{Float64}(n_sims) | |
for s in 1:n_sims | |
for i in 1:n |
This file contains 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
using Distributions | |
using HypothesisTests | |
n_sims = 100_000 | |
n = 25 | |
x = Array{Float64}(n) | |
y = Array{Float64}(n) | |
p_x = Array{Float64}(n_sims) | |
p_y = Array{Float64}(n_sims) | |
p_d = Array{Float64}(n_sims) |
This file contains 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
function construct_x(x9) | |
x = fill(0, 9) | |
r = fill(0, 9) | |
x[9], r[9] = x9, 0 | |
x[8], r[8] = fld(7 * x[9], 6), rem(7 * x[9], 6) | |
x[7], r[7] = fld(7 * x[8] + 1, 6), rem(7 * x[8] + 1, 6) | |
for i in 7:-1:2 | |
x[i], r[i] = fld(7 * x[i + 1] + 1, 6), rem(7 * x[i + 1] + 1, 6) | |
end |
This file contains 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
> x <- 1:8 | |
> y <- c(1, 1, 2, 3, 5, 8, 13, 21) | |
> summary(lm(y ~ x - 1)) | |
Call: | |
lm(formula = y ~ x - 1) | |
Residuals: | |
Min 1Q Median 3Q Max | |
-3.922 -3.306 -2.422 -0.326 7.157 |
This file contains 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") | |
# Population size | |
n <- 2500 | |
# Sessions per user if assigned to test | |
sessions_test <- as.integer(exp(rnorm(n, 0.5, 1))) | |
# Sessions per user if assigned to control |
This file contains 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
using Distributions | |
function simulate_coupled(v0, n, t_max, allow_debt) | |
cur = fill(v0, n) | |
nxt = copy(cur) | |
for t in 1:t_max | |
for i in 1:n | |
j = rand(1:n) | |
if allow_debt |
This file contains 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
n <- 100000L | |
x <- rnorm(n, 0, 1) | |
y <- -x | |
cor(x, y) | |
for (z in c(10, 100, 1000, 10000, 100000)) { | |
rho <- cor(c(-z, x, z), c(-z, y, z)) | |
print(paste0("z = ", z, "; rho = ", rho)) |
This file contains 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") | |
n <- 10000 | |
s_e <- 0.01 | |
x1 <- runif(n, -10, 10) | |
x2 <- runif(n, -10, 10) | |
y <- sin(x1 * x2) + rnorm(n, 0, s_e) | |
df <- data.frame(y = y, x1 = x1, x2 = x2, z = x1 * x2) |