Leanpub Header

Skip to main content

Probability Etudes in Common Lisp

Interactively learn probability using Common Lisp

Probability Etudes in Common Lisp
This book is 100% completeLast updated on 2026-08-16

Minimum price

Free!

$10.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

Here, dear reader, we cover sample spaces and the basic axioms of probability, then move through conditional probability, random variables, named distributions, the great convergence theorems, Monte Carlo methods, Bayesian inference, and finally Markov chains.

Share this book

Author

About the Author

Mark Watson

Mark Watson is a consultant specializing in LLMs, deep learning, machine learning, knowledge graphs, and general artificial intelligence software development. He uses Common Lisp, Clojure, Python, Java, Haskell, and Ruby for development.

He is the author of 20+ published books on Artificial Intelligence, Deep Learning, Java, Ruby, Machine Learning, Common LISP, Clojure, JavaScript, Semantic Web, NLP, C++, Linux, and Scheme. He has 55 US Patents.

Mark's consulting customer list includes: Google, Capital One, Olive AI, CompassLabs, Disney, Sitescout.com, Embed.ly, and Webmind Corporation.

Mark wrote ten traditional published books for McGraw Hill, Springer Verlag, J Wiley, and Morgan Kaufman publishers before adopting the LeanPub self-publishing platform.

The Leanpub Podcast

Podcast

Podcast Episode

Contents

Table of Contents

Preface

  1. How To Read This Book
  2. Running the Examples
  3. Acknowledgments

Introduction

  1. Why Study Probability?
  2. What This Book Covers
  3. A Note on the Code
  4. How Probability Connects to the Rest of Mathematics

Basic Probability

  1. A Brief History
  2. Interpretations of Probability
  3. Sample Spaces and Events
  4. Set Operations on Events
  5. The Event Space and the Probability Triple
  6. The Kolmogorov Axioms
  7. The Classical Definition of Probability
  8. The Complement Rule
  9. Running the Example
  10. Why This Matters
  11. Problem Set

Conditional Probability

  1. Why Conditional Probability?
  2. The Definition of Conditional Probability
  3. The Multiplication Rule and the Chain Rule
  4. Independence
  5. The Law of Total Probability
  6. Bayes’ Theorem
  7. Simpson’s Paradox
  8. Running the Example
  9. Why This Matters
  10. Problem Set

Discrete Random Variables

  1. From Events to Random Variables
  2. What Is a Random Variable?
  3. Indicator Random Variables
  4. The Probability Mass Function
  5. The Cumulative Distribution Function
  6. Expected Value
  7. Variance and Standard Deviation
  8. Standardization
  9. Moments and the Moment Generating Function
  10. Concentration Inequalities
  11. Three Example Distributions
  12. Additional Computations in the Program
  13. Running the Example
  14. Why This Matters
  15. Problem Set

Binomial and Geometric Distributions

  1. Bernoulli Trials
  2. The Binomial Distribution
  3. The Geometric Distribution
  4. The Memoryless Property
  5. Other Distributions from Bernoulli Trials
  6. Real-World Applications
  7. Running the Example
  8. Why This Matters
  9. Problem Set

Continuous Distributions

  1. Why Continuous Random Variables?
  2. From Probability Mass to Probability Density
  3. Expectation and Variance for Continuous Variables
  4. Numerical Integration
  5. The Uniform Distribution
  6. The Exponential Distribution
  7. The Normal Distribution
  8. Other Named Continuous Distributions
  9. The Maximum Entropy Viewpoint
  10. Transformations of Random Variables
  11. Why This Matters
  12. Problem Set

Law of Large Numbers

  1. Historical Roots
  2. The Sample Mean
  3. The Weak Law of Large Numbers
  4. The Strong Law of Large Numbers
  5. Modes of Convergence
  6. When the Law of Large Numbers Fails
  7. Why This Matters
  8. The Simulation
  9. Running the Example
  10. A Practical Observation
  11. Problem Set

Central Limit Theorem

  1. A Brief History
  2. The Theorem
  3. Why This Is Remarkable
  4. Why It Is True: A Sketch via Generating Functions
  5. Rate of Convergence: Berry-Esseen
  6. The Simulation
  7. Running the Example
  8. The Theoretical Basis for Statistical Practice
  9. How Large Does n Need to Be?
  10. Beyond i.i.d.: Extensions of the CLT
  11. Why This Matters
  12. Problem Set

Monte Carlo Methods

  1. A Short History
  2. The Core Idea
  3. Monte Carlo Integration
  4. Estimating Pi
  5. Standard Error
  6. Running the Example
  7. The Cost of Monte Carlo
  8. Variance Reduction
  9. Quasi-Random Sequences
  10. Buffon’s Needle: An Older Pi Estimator
  11. Applications Beyond Pi
  12. Why This Matters
  13. Problem Set

Bayesian Inference

  1. Two Paradigms of Statistics
  2. The Bayesian Framework
  3. The Choice of Prior
  4. Conjugate Priors
  5. The Update Rule
  6. Point Estimates and Credible Intervals
  7. Prediction: The Posterior Predictive
  8. The Example: Estimating a Coin’s Bias
  9. Running the Example
  10. The Laplace Rule of Succession
  11. Prior Sensitivity
  12. Why This Matters
  13. Problem Set

Markov Chains

  1. Andrey Markov and the Origin of Markov Chains
  2. The Markov Property
  3. A Weather Model
  4. Evolving the Distribution
  5. Classification of States
  6. The Stationary Distribution
  7. Finding the Stationary Distribution
  8. Why the Chain Converges: The Spectral View
  9. Running the Example
  10. Hitting Times and First-Step Analysis
  11. Applications of Markov Chains
  12. Beyond Discrete Time
  13. Why This Matters
  14. Problem Set

An Embedded Probabilistic Programming Language

  1. What Inference Computes
  2. Unconstrained Space and the Jacobian
  3. Three Ways to Find the Posterior
  4. Forward-Mode Automatic Differentiation
  5. The Distribution Library
  6. Support Transforms
  7. The Model DSL: defmodel, sample, observe
  8. The Example Data
  9. The Three Inference Engines
  10. Diagnostics: ESS and R-hat
  11. Running the Example
  12. Wrap Up
  13. Problem Set

Wrapping Up

  1. The Arc of the Book
  2. Where To Go From Here
  3. The Value of Implementation
  4. Final Thoughts

Further Reading

  1. General Probability and Measure
  2. Statistics, Bayesian Methods, and Machine Learning
  3. Markov Chains and Monte Carlo
  4. Papers Behind Chapter 11
  5. Special Functions

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub