On a world Turing I was recently one of the luck 10,000 when I stumbled across these implementations of a Reaction-Diffusion system in APL & BQN. Investigating more, it turns out these ideas date back at least as far as Alan Turing . Karl Sims’s particularly useful tutorial describes the Gray-Scott model. In this, the system describes the interactions of two “chemicals” \(A\) and \(B\) according…
While working as an Applied Research Mathematician for the US Department of Defense, I received my Ph.D. in Applied Mathematics from UNC Charlotte’s Math Department in the Spring of 2013. After that, I worked as a Senior Data Scientist for Quantifind, Inc . Then I was a Lead Research Scientist, Quantum Advantage for Rigetti Computing , before starting my current role as Chief Scientist at…
I shall laugh myself to death at this puppy-headed monster Last year, Matt Keeter put out the Prospero challenge . It’s a really great playground for learning about programming languages, compilation, constructive solid geometry , and more! I’m a bit late to the game, but in my “spare time,” I’ve been working on my own attempt. You can see the code here . So far, my approach has been pretty…
Don’t be mean I got curious about parallelism—in Rust, but the same ideas probably apply elsewhere—comparing using multiple CPUs via rayon and SIMD via portable_simd . I suspected that which one would be the fastest would be highly dependent on multiple factors, like the amount and distribution of the data involved and the complexity of desired computation. To investigate, I wrote some code to…
Happy \( \pi \) Day In honor of today’s date , I played around with different ways of approximating everyone’s favorite constant in Dyalog APL . What follows are translations of a few entries from this fun Wikipedia list. I tried to avoid anything that felt like cheating, e.g. using trigonometric functions or other constants like \( \phi \). First, we set index-origin to its correct value ⎕io←0 .…
A wild e appears Here’s a fun math tidbit : Select a random number between 0 and 1. Now select another and add it to the first. Keep doing this, piling on random numbers. How many random numbers, on average, do you need to make the total greater than 1? Answer: 2.71828…. — John Derbyshire, Prime Obsession The inimitable MathWorld has more info on it, and the first link above has a nice proof…
Random Art, Revisited In a previous article , we played around with implementing a tiny programming language for generating random art. In that article and the accompanying code , we implemented a trick I learned from this post , specifically matklad ’s response. In learning more about programming language implementation, I came across this wonderful post by Professor Adrian Sampson, which…
Not feeling it Today isn’t great. I don’t like it. So here, to take minds off things, have a fractal. Ugly Rust code, using image and num_complex : use image :: { ImageBuffer , Rgb }; use num_complex :: Complex ; fn main () { let img = 3200 ; let scale = 3.0 / img as f32 ; let max_iter = 42.0 ; let imgbuf = ImageBuffer :: from_par_fn (img, img, | x, y | { let c = Complex :: new (x as f32 * scale -…
A few of my favorite things The Tropical (min-plus) semiring is one of my favorite examples of how changing one’s perspective can make difficult problems much simpler. [1] In this semiring, instead of using the usual addition and multiplication, we replace them with minimum and addition, so, for instance, \( 1 \oplus 2 = 1 \) and \( 3 \otimes 2 = 5 \). I’ve written and presented about this before.…
New paper, who dis? I’m excited to announce that our paper on using classification performance on imbalanced datasets as a proxy for measuring generative model quality up on the arXiv ! It combines a lot of interesting techniques, like post-hoc testing, the Bayesian boostrap, and explainable AI techniques, all to get an idea of how well a quantum generative model performs. Please check it out!
The Original Robert Smith, a.k.a. stylewarning , has a lovely blog post that walks through implementing an interpreter for a “general-purpose quantum programming language called \( \mathscr{L} \).” In only 150 lines of Common Lisp, the implementation is featureful, self-contained, and a delight to read. Imitation is the highest form of flattery At first I was content with only reading the post and…
PL Resources Everywhere In playing around with OCaml , I’ve spent some spare time perusing more programming language resources. There are a bunch out there, especially in this era of online learning; for instance, Cornell has made some great resources available. In looking specifically for more ML-ish [1] flavored ones, I came across this fun undergrad homework set. In the second problem, it asks…
Why and wherefore I’ve wanted to level up my OCaml understanding for a while now, but between doing a fair amount of work in Rust at my current job and already having a bit of Haskell, I wasn’t sure I could justify the “distraction.” But between some excellent resources available online , some interesting reading (more on that in a moment), and the newest 5.0.0 release , I decided it was time to…
A wretched hive of scum and villainy With it being my birthday today, I took a little bit of time to noodle on a pet project. For all the computer science classes I’ve taken, books I’ve read, course notes I’ve looked through, and code I’ve written, reviewed, or perused, I had yet to implement any sort of Lisp-like language myself. Having decided to change that, I’ve been toying around for the last…
Code or it didn’t happen I’ve been noodling with a Rust implementation of the ideas from this talk , and decided I should probably share it—or at least put it up online in case my laptop crashes. The repo is available here .
Previously… We’ve talked previously about implementing a time-traveling key-value store. Having worked more with Rust in the interim, I tried my hand at a Rust implementation. Rust’s type system, standard library, and attention to pedantic details make this my favorite version yet. Implementation The standard library provides everything we need: use std :: collections :: BTreeMap ; use std :: time…
New paper I’m excited to announce that our paper on using quantum ML to predict weather radar products is up on the arXiv ! What’s more, per the press release , we’ll be presenting the paper at the Artificial Intelligence for Humanitarian Assistance and Disaster Response Workshop at NeurIPS 2021 .
Programming with types for understanding One of the best uses of the type system I’ve seen is the Build systems a la carte paper. In it, the authors use Haskell’s types to outline and explore the problem domain in really novel ways. I wanted to understand CRDTs more, so I made a thing. It’s nowhere near the level of Build systems a la carte , but I found it useful. Understanding CvRDTs CRDTs are…
Introduction The other day, someone asked me about the difference between “an API and a regular webpage.” After understanding more about the context of their question, I tried to come up with a decent explanation about the differences between a server sending HTML pages and one handling REST API requests. As a thousand words leave not the same deep impression as does a single deed , I thought I’d…
Introduction It’s probably not news to you, but folks behind the PostgreSQL Database have made an incredible piece of software. It’s fast, it can handle loads of data, and it has interesting builtin functions and index types for almost anything you might need. For this post, though, I’d like to highlight how it facilitates DB maintenance tasks by eating its own dog food —that is, how answering…
Introduction In an effort to both post more than once a year and clean out some silly things from my ~/tmp directory, here’s a quick post about two programming shenanigans. Perhaps unsurprisingly due to its history of jocularity, both originate with Perl. Bleach Damian Conway is a truly prolific member of the Perl community. One of Conway’s less serious contributions is the Acme::Bleach module,…
Introduction In my last post I talked about a time traveling key-value store implementation in some functional Scala. After thinking about the problem more— probably a little too much —I decided to try my hand at another implementation, this time in Python again. Rather than going the purely functional route, though, I wanted to focus on how we represent the data internally. Since we essentially…
Never Give Up Once upon a time I interviewed for an ML/DS/software engineering position. I didn’t get the gig (as the inimitable Time Hopper says, never give up ), but came away with a fun programming exercise. In the room, I put together some reasonable Python to solve and test it, but I wanted to try my hand at using cats-effect to work through this in some functional Scala. What is Your Problem…
Algebraic Structure, Computational Benefits I recently gave a talk at work titled “Algebraic Structure, Computational Benefits.” In it, I defined a few basic (as in fundamental, not as in easy) structures like semigroups, monoids, and semirings, and I discussed the computational benefits one can derive by making these structures explicit in code, like: the most generic of generic algorithmic code…
Combining previous work with new things In a previous post , we explored an example from Persi Diaconis using the Fourier Transform to change a collection of permutations into a table where the (i, j) entry is the number of voters who ranked candidate i in place j ; this transformation consists of first mapping each permutation to its matrix representation, then adding the matrices together.…
Sorry Apologies, as ever, for taking so incredibly long between posts. That said if the inimitable Roger Peng can get away with letting some time lapse while working on a project, perhaps you can forgive me? Sometimes it takes a while for a project to get going. — Roger D. Peng (@rdpeng) August 24, 2017, Twitter Back to Python After a long time in the Scala wilderness, I’ve recently had a chance…
Recently I wrote a small Rust executable for work. I wrote it on my Apple laptop, but wanted to run it on our Linux servers. This note hopes to document how I did it so that I and others may repeat my experience. Note: I only managed to pull this off because of the helpful folks on the #rust and #rust-internals IRC channels. Thanks everyone! Set up There are plenty of tutorials out there for…
Well that’s weird I ran into an interesting problem in a recent Scala project. Let’s set the scene … Quickly Checking in Scala In the project in question, I reached for a library to do a fair amount of JSON parsing. I hadn’t used the library before, so I ended up writing some ScalaCheck tests for the convenience/wrapper functions I made. One test involved writing data to a temporary file, reading…
Hola Is it poor form to start each post with an apology for the time elapsed since the previous one? Either way, hello dear reader. Beyond being the father of a rambunctious young’un, things have changed around here since we last spoke. New Job, Plus Why Tech Companies Should Hire in DC In January I started a new gig as a Data Scientist for Quantifind . I’m excited about the opportunity, and the…
Small baby, no sleep make Graham a dull blogger Apologies, readers, for my long absence. My family grew this last year, so I’ve had less time for writing. Feynman’s Blackboard On Richard Feynman’s blackboard at the time of his death was the quote “What I cannot create, I do not understand.” Powerful words, and I definitely think there’s some truth to them. Recently I came across a popular,…
The Story To give an example of working with data while still having fun, I’ve decided to tackle Transformers . Specifically, after finding this dataset someone scraped together from Wikipedia, I thought it’d be interesting to see if we can predict the affiliation (Autobot vs. Decepticon) of a character using one of Scikit-Learn ’s naive Bayes classifiers . Enough chit-chat; let’s roll up our…
Apologies Sorry for taking so long to post again, fearless reader; I’ve recently moved to a new house, so most of my outside-of-work-energy has been spent dealing with all that entails. This also means that this post is probably not as polished as I may have hoped. Intro While attempting to port some academic code to a, shall we say, cleaner setup for work, I had some trouble with implementing a…
Porting academic code is fun, I swear I’ve been chewing on a rather tough programming problem at work recently involving porting code from a collection of different languages to a C++11 production-ish-looking thing. Really, the project is just to get a cohesive version of the interesting (but entirely academic, not remotely production-ready) code from a published paper. Even with the previously…
Isn’t all science “Data Science?” I’m an applied research mathematician in my day job, which on a day-to-day basis puts me somewhere between mathematician, software developer, machine learning practitioner, and statistician. In other words, I’m probably what’s called a Data Scientist nowadays. See the image below for how some people feel about that term; [1] I’m a bit ambivalent about it myself.…
Diaconis does something cool, video at 11 Persi Diaconis is an interesting character. He dropped out of high school at 14 to become a professional magician, got a Ph.D. from Harvard, won a MacArthur “genius grant,” and is now a mathematician and statistician at Stanford University. He also does interesting math; today I’ll talk about an example from a paper [1] of his that I found particularly…
Coding for Interviews In order to up my programming chops, I’ve signed up for this newsletter . It’s been fun, though I don’t typically have the time/energy to answer the questions. Somewhat serendipitously, though, they sent out a question that I’ve poked my nose into recently: the N Queens Puzzle . My Solution I’ve taken the approach this newsletter seems to prefer: writing my thinking and…
How to count without counting I’ve been messing about with a few different things lately, one of which is the HyperLoglog algorithm . Others have already written about this extensively, so I have nothing terribly new to contribute; I just wanted briefly discuss what it is and show some code. In Brief While it’s a little zen sounding, HyperLogLog is a way of counting the number of unique items—say,…
All shutdown and no work makes Graham a dull boy I’ve been reading SICP recently in my quest to extend my Computer Science knowledge. This is a task I’ve attempted before but never really had the time to devote a solid chunk of brain-power to. However, due to recent events , I find myself with more time on my hands than usual. [1] SICP to the rescue This post will be short, but I imagine I’ll…
Richard Stanley, Captain of Counting I recently received an email about a math conference in honor of Richard Stanley’s 70th birthday. For those of you who don’t know, Stanley is an expert in combinatorics and author of the two volume magnum opus Enumerative Combinatorics which (among a bunch of other very interesting math) champions the idea of the combinatorial proof —a way of proving a…
Dear Statistics, I apologize for not having taken you seriously until this year. I said that you aren’t Mathematics; that’s true, but not in the (derisive) way I meant it. You aren’t Math in the same way that Physics isn’t Math—you sure use a whole lot of Math to do some very interesting and important things. Really, you are the science of data; [1] you enable us to learn and make decisions in a…
EDIT In the more than ten years since I first wrote this, I have learned a lot about programming, programming languages, compilers, interpreters, and more; and The ecosystem around this kind of idea has changed a lot! See, for instance, mojo . I’ll leave the rest of this post untouched; please forgive past Graham’s naivete! Python type annotations In the 3.x series of the Python language, there’s…
Introduction The inimitable Programming Praxis , to which I owe much of my programming abilities [1] , posted an exercise that was seemingly simple but has some surprising depth to it. Since it’s been a little while since the problem was posted, I have few qualms about discussing it here. However, don’t read on if you prefer to solve the problem yourself first. The question Programming Praxis…
So… here’s my first post. I’ve been inspired to keep a digital notebook/record of sorts, mostly to keep me honest about continuing my education; the theory is that if I have something to keep me accountable, some place to post my work, then I’ll keep working. Since this is my first post, I’m going to use this space for two things: as a play sandbox to see how things render to dicuss some of the…