View GenericCategoricals.jl
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} |
View permutation_test.py
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) |
View parsetree.jl
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
module TreeFromString | |
using PEG | |
import Base: show | |
struct Tree{T} | |
val ::T | |
children ::Vector{Tree{T}} | |
end |
View bootstrap.py
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 bootstrap_test(higher, lower, n=100000): | |
xs = higher | |
ys = lower | |
m = np.mean(xs) - np.mean(ys) | |
zs = np.concatenate((xs,ys)) | |
boots = np.random.choice(ys, size=(n,len(zs))) | |
return np.sum(np.mean(boots[:,0:len(xs)], 1) - np.mean(boots[:,len(xs)+1:], 1) > m) | |
# test whether the mean of the array `higher` is higher than the mean of the array `lower` | |
def bootstrap_pvalue(higher, lower, n=100000): |
View index.html
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Vega Lite Barplot</title> | |
<!-- Import Vega 4 & Vega-Lite 3 (does not have to be from CDN) --> | |
<script src="https://cdn.jsdelivr.net/npm/vega@4"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-lite@3.0.0-rc12"></script> |
View CompoundDistributions.jl
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
module CompoundDistributions | |
using StatsFuns.RFunctions: betarand, gammarand | |
using SpecialFunctions: lbeta | |
using LogProbs | |
# distribution types | |
export BetaBern, DirMul, DirCat, UniCat, CatDist, ChineseRest | |
# conditional distribution type |
View example_plot.jl
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
df = DataFrame(x=randn(500), y= randn(500)) | |
df |> vlplot( | |
mark = :point, | |
encoding = ( | |
x = (field=:x, typ=:quantitative), | |
y = (field=:y, typ=:quantitative) | |
) | |
) |
View julia_tools.jl
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
partial(f, args...) = let args = args; (more...) -> f(args..., more...) end |
View fibs.jl
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 Base.Iterators: take | |
import Base: iterate, IteratorSize, eltype | |
struct Fibs end | |
iterate(::Fibs, (i, j) = (1, 1)) = i, (j, i+j) | |
IteratorSize(::Type{Fibs}) = Base.IsInfinite() | |
eltype(::Type{Fibs}) = Int | |
# collect the first ten fibs in an array |
View using_seaborn_in_julia.jl
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
import Seaborn | |
import Pandas | |
# convert julia dataframe into a pandas dataframe | |
panda(df) = Pandas.DataFrame(Dict(n => df[n] for n in names(df))) |
NewerOlder