Preface

This book was written with the assistance of Anthropic’s Claude Opus 4.6, largely within the one-million-token context window of Claude Code. That disclosure made, let me explain what this project actually is and why it exists.

Population genetics is blessed with powerful algorithms – but cursed with inaccessible ones. Many of the field’s most important methods live inside papers and codebases that assume years of specialized training to read, let alone reimplement. They rarely come with manuals, guided tours, or on-ramps for the curious outsider – or even for the insider who works on a different corner of the field. This book is an attempt to change that: to make the algorithms not only open but genuinely accessible, with all the prerequisites laid out and every derivation shown in full.

I assembled these chapters during my transition from the University of Oregon to the University of Pennsylvania, at my own expense and in my own time. The book is freely available because I believe science should be. It was not, however, free to create – and I mention this only to underscore that the motivation was personal before it was practical. I wanted to understand these algorithms more deeply myself. Writing them out, gear by gear, was the surest way I knew how.

Nothing here is meant to diminish the original work. Each algorithm in this book represents a serious intellectual achievement – the kind that earns PhD titles and advances entire subfields. The goal is translation, not judgment: to take ideas that were expressed for expert audiences and re-express them for anyone willing to learn. The content may contain errors – mathematical, conceptual, or otherwise – and should ideally be read in combination with the original journal articles, which remain the authoritative source for each method.

The book is accompanied by watchgen, a Python package that provides minimal, self-contained implementations of every algorithm covered. These mini implementations are not production tools; they are pedagogical companions – small enough to read in one sitting, complete enough to run on toy examples, and tested enough to give you confidence that the math on the page actually works. Think of them as the movements you build on the workbench: not meant for sale, but meant to teach your hands what your eyes have read.

Finally, this project is an open invitation. I expect errors. I expect gaps. I expect places where a domain expert will wince and reach for a red pen. Good – that is the point. I welcome collaborators who want to cross-check derivations, correct mistakes, improve explanations, add chapters, or simply point out where things could be clearer. The ambition is a living resource that grows more accurate and more useful over time, built by the community it is meant to serve.

Looking Ahead

The mini implementations in watchgen are pedagogical – deliberately simple, deliberately slow. But the landscape is shifting fast. AI models are growing more capable at an extraordinary pace, and within the next year it may become realistic to go further: to use these same models to produce a unified, production-grade software package that brings the algorithms covered here under a single roof – correct, tested, interoperable, and maintained. What was once a decades-long software engineering effort shared across many groups may soon be achievable by a small team working with the right tools. This book, with its explicit derivations and reference implementations, is designed to serve as the foundation for exactly that kind of effort – a detailed blueprint that a future, stronger model can read, verify, and build upon.

A Note on Versioning

This is version 0.1 – an unverified draft. No chapter has yet been reviewed by a domain expert, and I make no claim that any derivation is free of error. Future versions will name the individuals who have verified each chapter, and contributors who substantially improve the content – whether by correcting proofs, rewriting sections, or adding new chapters – will be invited as co-authors. Science is a collective enterprise; this book should be too.

Kevin Korfmann
Philadelphia, 2025