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...
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...
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...
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...
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...
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...
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...
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....
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...
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...