Skip to content

Instantly share code, notes, and snippets.

@zelaznik
zelaznik / my_count.sql
Created August 14, 2024 15:00
Custom Agg Functions Notes
CREATE OR REPLACE FUNCTION my_count_state(state integer, value anyelement)
RETURNS integer AS $$
BEGIN
IF value IS NOT NULL THEN
RETURN state + 1;
ELSE
RETURN state;
END IF;
END;
$$ LANGUAGE plpgsql;
@zelaznik
zelaznik / my_avg.sql
Created August 14, 2024 15:12
Custom Agg Functions
CREATE TYPE avg_state AS (
total numeric,
count integer
);
CREATE OR REPLACE FUNCTION my_avg_state(state avg_state, value numeric)
RETURNS avg_state AS $$
BEGIN
IF value IS NOT NULL THEN
state.total := state.total + value;
@zelaznik
zelaznik / binomial.js
Last active November 4, 2024 20:04
Javascript Chicago Lightning Talk Outline (WIP)
// A pure Javscript implementation of binomial distribution
// This is for educational purposes. These numbers can become unreliable
// when the numerators and denominators get too big. This is because
// of floating point arithmetic.
//
// Use a more robust statistical library for mission critical calculations
function factorial(n) {
let total = 1;
for(let i=n; i>1; i--) {
@zelaznik
zelaznik / normal_approximation_ab_testing.md
Created November 12, 2024 21:12
normal_approximation_ab_testing

Attempt #2, Using Normal Distribution

Find the combined click-through rate:

$$\widehat{\mu} = \frac{k_a + k_b}{n_a + n_b} = \frac{10 + 13}{100 + 100} = \frac{23}{200} = 0.115 $$

Find the variance of the click through rate:

You can look up the mean and variance of a distribution on Wikipedia. This is the distribution of a single visitor and whether this visitor signs up (1) or not (0).

A/B Testing Statistics

Find the average click through rate:

We're assuming the opposite, so we're assuming there's one average click through rate for both pages:

$$\widehat{\mu} = \frac{k_a + k_b}{n_a + n_b} = \frac{10 + 13}{100 + 100} = \frac{23}{200} = 0.115 $$

Now we also have to find the variance of the click through rate:

#!/usr/bin/env bash
# red-green-refactor-validator.sh
# Validates test-driven development red-green-refactor workflow
#
# Exit codes:
# 0 - Validation successful (tests failed on old code, passed on new code)
# 1 - Validation failed (no tests changed, or tests didn't follow red-green pattern)
# 2 - Precondition failed (unstaged changes exist)
# 3 - Script error (stash/restore failed)
@zelaznik
zelaznik / talk_outline.md
Last active March 3, 2026 13:17
Power is Nothing Without Control: Using Deterministic Controls to Harness the Power of Agentic AI

Power is Nothing Without Control

Using Deterministic Controls to Harness the Power of Agentic AI


The Anchor

When I was a kid I thought I was going to grow up to be an automotive engineer. I read Car and Driver cover to cover every month. One ad that stuck with me for 30 years was for a brand of tires. The Pirelli "Power is Nothing Without Control" campaign. A barefoot sprinter making a tight corner, angled so steeply he's nearly horizontal to the ground. Raw capability at its limit — and the only thing keeping him from becoming a skid mark is the interface between his foot and the ground. That interface is what this talk is about.

https://www.alamy.com/stock-photo-1990s-uk-pirelli-magazine-advert-85361428.html?imageid=FF50E53A-9F51-4B71-9235-322BE9B7D5DE&pn=1&searchId=8d875d0f24101d78cd7ffdc386cb1009&searchtype=0