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
def permutation_simulation(higher, lower, n=100_000): | |
xs = higher | |
ys = lower | |
m = np.mean(xs) - np.mean(ys) | |
zs = np.concatenate((xs, ys)) | |
z_perms = np.random.choice(ys, size=(n, len(zs))) | |
x_perms = z_perms[:, 0:len(xs)] | |
y_perms = z_perms[:, len(xs)+1:] | |
x_perm_means = np.mean(x_perms, 1) | |
y_perm_means = np.mean(y_perms, 1) |
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 Random: AbstractRNG | |
using StatsBase: proportionmap | |
using Test | |
# Generic categoricals are also known as empirical measures. | |
struct GenericCategorical{T} | |
mapping :: Dict{T, Float64} | |
values :: Vector{T} | |
probs :: Vector{Float64} |
OlderNewer