Skip to content

Instantly share code, notes, and snippets.

View tdunning's full-sized avatar

Ted Dunning tdunning

View GitHub Profile
# model two bodies orbiting each other with a bunch of near zero mass particles around them
# the first time you run this, Julia will ask you if you want to install them (say yes) and
# then spend a fair bit of time compiling them. That won't happen on subsequent loads.
"""
To load and run this code, start Julia and then "include" this file:
```
julia> include("orbits.jl")
┌ Info: start
│ size(u0) = (408,)
function normalize_rows(x)
n = sqrt.(sum(x .* x, dims=1))
x ./ (n + (n .== 0))
end
"""
Project and plot high-dimensional data.
Data is n x d where each row is a point. The projection p is n x 2.
"""
@tdunning
tdunning / T250-6-measurements.md
Last active December 17, 2024 08:21
Calculating toroidal coil inductance

Summary

While building a filter for a WSPR beacon, I noticed that the primary inductor in the circuit behaved as if it had more inductance than expected.

To learn more about what was happening, I built a test jig made up of a single 180pf SMD capacitor with two SMA connectors and used a vector network analyzer (VNA) to measure the resonant frequency of test coils to determine their effective inductance. This gave me enough data to derive an empirical formula

The idea of content-based recommendation is that instead of looking purely at a history of
how users interact with items where both users and items are considered as things we know
nothing about (other than their interactions), we can consider the features of the items.
By content here, we might consider actual textual descriptions, but we might also consider
more structured information about the objects like their color or whether they are shoes,
books or music.
If we look at the content associated with items, we can restate the user x item history as
a user x content-feature history. That is to say that we can look at what content features
our users interacted with as opposed to which items. Essentially, we are recommending features
Pragma version;
CREATE TABLE distributors (
did integer CHECK (did > 100),
name varchar(40)
);
insert into distributors values (200, 'a');
insert into distributors values (201, 'b');
select min(columns('d.*')) from distributors;
@tdunning
tdunning / csv-sample.csv
Created January 23, 2022 21:11
random data in CSV form
x1 x2 x3
0.7231422916301575 0.819657781416707 0.6567508886461839
0.4020425739176958 0.1549076251851813 0.4282647678658029
0.4629109586444531 0.9094363294197141 0.1236688659876839
0.747467460858015 0.2428975528400832 0.6360313817514556
julia> A = 3 # this is \Alpha
3
julia> Α = 4 # this is A
4
julia> Α == A # they aren't the same
false
julia> x′ = rand(2,2) # this is x\prime
library (dplyr)
data = read.csv('median-error.csv')
png("max-error-uniform.png", width=1200, height=1000, pointsize=25)
i = -3.8
boxplot(abs(error) ~ delta, (data %>% filter(n0==20)), ylim=c(0, 0.05), xlim=c(0.6,4.4), boxwex=0.1, at=(1:4)+i/11, xaxt='n', xlab=expression(delta), cex.lab=1.4)
axis(side=1, at=1:4, labels=c(50,100,200,500))
for (nx in c(20, 50, 100, 1000, 10000, 100000)) {
@tdunning
tdunning / figure.r
Created June 18, 2021 07:30
Snippet of R to recreate an analysis of t-digest interpolation on real data
# Analysis of how two t-digests see some sample data
png("figure.png", width=1200, height=1000, points=30)
# the first few actual data points with filler for the remainder
d = c(241, 543, 575, 702, 890, 1530, 1940, 2166, 2168, rep(3000,33))
# the cumulative distribution function
f = ecdf(d)
# plot the actual CDF
plot(x=d, y=f(d), xlim = c(700, 2300), ylim = c(0.08, 0.25), type='s',
xlab="Sample value", ylab="Cumulative Distribution Function",
cex.lab=1.3)
@tdunning
tdunning / lorenz-animator.jl
Created May 4, 2021 00:49
Animates the evolution of an initially tight group of points ... my intro to Julia
using DifferentialEquations
using Plots
using Statistics
using LinearAlgebra
function lorenz!(du, u, p, t)
x, y, z = u
σ, ρ, β = p