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,Random,StatsPlots,LinearAlgebra | |
dist = MvNormal(zeros(20),I(20)) | |
samp = rand(dist,200) | |
lps = [logpdf(dist,c) for c in eachcol(samp)] | |
histogram(lps; label="lp of 200 draws") |
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
## from https://statmodeling.stat.columbia.edu/2024/03/07/relating-t-statistics-and-the-relative-width-of-confidence-intervals/#comment-2335932 | |
# but fixed up due to blog damage | |
nsim = 10000 | |
lengthOfCI = rep(NaN, nsim) | |
containsPM = rep(NaN, nsim) | |
for(i in 1:nsim){ | |
y = rnorm(10, 0, 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 HCubature, LinearAlgebra, StatsPlots, QuadGK, StaticArrays | |
# Define a function that describes the density | |
# as a function of the radial distance from the center of the galaxy. This is a | |
# dimensionless quantity (mass/area) / (mass/area at zero distance) | |
# r is a dimensionless distance, radius as a fraction of the galactic scale radius | |
function rho(x) | |
exp(-sqrt(x[1]^2+x[2]^2)-5.0*abs(x[3])) |
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, Random, StatsPlots, Turing | |
# We have a pallet of 100 jugs of Orange Juice, each is a 2L jug. | |
# they are filled by a machine which may have a flaw. we would like to find | |
# the avg amount of OJ in a jug by taking a sample of 20 | |
# this is a finite population, and the actual distribution of volumes is just given | |
# by 100 numbers. we'll say they are something like this: | |
Random.set_global_seed!(1234) |
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 Pkg | |
Pkg.activate(".") | |
Pkg.add(["Turing","Distributions","ApproxFun","QuadGK","StatsPlots","LinearAlgebra","DataFrames"]) | |
using Turing, Distributions, ApproxFun, QuadGK, StatsPlots, LinearAlgebra, DataFrames | |
# a prior over functions that go up then come down... First let's see how ApproxFun works | |
Random.set_global_seed!(123456) | |
f = Fun(Chebyshev(Interval(0..100)),randn(12)) |
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, HypothesisTests, DataFrames, DataFramesMeta, StatsPlots | |
function dowork(effsizes,reps) | |
res = typeof((effsize=1.0,meanval=1.0,pval=0.1))[] | |
for s in effsizes | |
for r in 1:reps | |
sam = rand(Normal(s,1.0),15) | |
tt = OneSampleTTest(sam) | |
push!(res,(effsize=s,meanval=mean(sam),pval=pvalue(tt))) | |
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
# julia code to show that the mean of 14 samples from a 50/50 mixture | |
# of normal and uniform has extremely close to "normal" distribution | |
using Distributions, StatsPlots | |
meanvals = [mean([rand(Normal(0,1),7); rand(Uniform(-1,1),7)]) for i in 1:100000] | |
histogram(meanvals) | |
pop = [rand(Normal(0,1),10000); rand(Uniform(-1,1),10000)]; |
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
# A simple stateful firewall with some packet tagging, | |
# based originally on nftables archlinux wiki | |
# https://wiki.archlinux.org/index.php/nftables | |
## this assumes eth0 is LAN and eth1 is WAN, modify as needed | |
flush ruleset | |
## change these |