Tom Moertel's Blog

https://blog.moertel.com/ (RSS)
visit blog
Sampling with SQL
23 Aug 2024 | original ↗

By Tom Moertel Posted on August 23, 2024 Tags: sampling, sql, probability, poisson process, exponential distribution, statistics Sampling is one of the most powerful tools you can wield to extract meaning from large datasets. It lets you reduce a massive pile of data into a small yet representative dataset that’s fast and easy to use. If you...

Dice Race (part 1)
24 Jun 2023 | original ↗

By Tom Moertel Posted on June 24, 2023 Tags: interview-problems, probability, dice-race In a dice race of degree \(m\) and length \(n\), each player chooses a sequence of \(m\) die rolls. Then we roll a die \(n\) times to generate the race sequence. The player whose sequence occurs first in the race sequence wins. If no player’s sequence occurs...

A Great Old-Timey Game-Programming Hack
14 Dec 2013 | original ↗

By Tom Moertel Posted on December 14, 2013 Tags: assembly, 6809, games, hacks A long time ago, when I was a college undergrad, I spent some time working on computer video games. This was in the 8-bit PC era, when the gaming hardware was almost impossibly slow by today’s standards. It might not surprise you, then, to learn that game programmers...

Tricks of the trade: Recursion to Iteration, Part 4: The Trampoline
12 Jun 2013 | original ↗

By Tom Moertel Posted on June 12, 2013 Tags: programming, recursion, iteration, python, recursion-to-iteration series, tail calls, data structures, trampolines This is the fourth article in a series on converting recursive algorithms into iterative algorithms. If you haven’t read the earlier articles first, you may want to do so before...

Tricks of the trade: Recursion to Iteration, Part 3: Recursive Data Structures
3 Jun 2013 | original ↗

By Tom Moertel Posted on June 3, 2013 Tags: programming, recursion, iteration, python, recursion-to-iteration series, tail calls, data structures This is the third article in a series on converting recursive algorithms into iterative algorithms. If any of what follows seems confusing, you may want to read the earlier articles first. This is an...

Lazy merging in Python using streams
26 May 2013 | original ↗

By Tom Moertel Posted on May 26, 2013 Tags: programming, python, iterators, streams, SICP, functional programming Recently while solving a programming puzzle in Python, I needed to merge a series of N iterators, each yielding values in sorted order, into a single iterator over the sorted values. The trick is that, when asked for a value from...

Tricks of the trade: Recursion to Iteration, Part 2: Eliminating Recursion with the Time-Traveling Secret Feature Trick
14 May 2013 | original ↗

By Tom Moertel Posted on May 14, 2013 Tags: programming, recursion, iteration, python, google code jam, puzzles, recursion-to-iteration series, tail calls This is the second post in a series on converting recursive algorithms into iterative algorithms. If you haven’t read the previous post, you probably should. It introduces some terms and...

Tricks of the trade: Recursion to Iteration, Part 1: The Simple Method, secret features, and accumulators
11 May 2013 | original ↗

By Tom Moertel Posted on May 11, 2013 Tags: programming, recursion, iteration, python, google code jam, puzzles, recursion-to-iteration series Alternative title: I wish Python had tail-call elimination. Recursive programming is powerful because it maps so easily to proof by induction, making it easy to design algorithms and prove them correct....

Odds and the evidence of a single coin toss
4 Mar 2013 | original ↗

By Tom Moertel Posted on March 4, 2013 Tags: probability, odds, bayesian, coin-toss-problem, reasoning, evidence A while ago I wrote about how to update your beliefs in light of the evidence contained within a single coin toss. My article ended with the tantalizing prospect of an easier way to do such updates using odds. That prospect is what...

The second-order-diff Git trick
18 Feb 2013 | original ↗

By Tom Moertel Posted on February 18, 2013 Tags: git, diff One of the things that Git makes safe and practical is bulk editing by way of “sledgehammer-and-review”: Apply some powerful (but potentially dangerous) sledgehammer to a bunch of files. Review the sledgehammer’s effects using git diff to make sure there was no collateral damage. If...

↑ these items are from RSS. Visit the blog itself at https://blog.moertel.com/ to find other articles and to appreciate the author's digital home.