Author Archives: David Bookstaber

Checking Probability and Statistics via Simulation

Did I get all these formulas right?

David Bookstaber's statistical formulae for Gaussian and Rayleigh parameter estimates and confidence intervals.

I’ve published the details on my Ballistipedia Github. I’ll explain how Monte Carlo simulation techniques enable anyone to verify whether these are correct. But first, the motivation:

Many shooting sports require relentless pursuit of precision in guns and ammunition. Amateur sportsmen spend thousands of dollars and hours a year trying to tweak their gear for marginal improvements in accuracy. Sadly, a lot of this effort is wasted because they lack an adequate understanding of probability and statistics.

Here is a common example: A shooter is tuning a load for a rifle. This involves assembling lots of ammunition in which the powder charge is varied by fractions of a grain over a range of acceptable values, then shooting the lots and seeing if any are exceptionally precise. But powder and bullets have become increasingly expensive, and each load and shot takes time, so there is constant pressure to draw conclusions from as few samples as possible. Compound this with the reality that humans are pattern-seeking machines who are so easily fooled by randomness that superstition is a hallmark of our species. Now we have legions of shooters going through the motions of experimentation but in the end making decisions based on essentially random noise.

As part of my renewed effort to apply rigorous statistical inference to amateur ballistics, I have been compiling formulas for p-values and confidence intervals on parameter effect size estimates for Gaussian, Exponential, and Rayleigh probability distributions.

When dealing with small samples there are bias correction terms that become increasingly relevant: For example, when n=3 failing to correct for bias leads to an estimate of standard deviation that is on average 20% too low! But how many degrees of freedom are involved? For a Rayleigh parameter estimate is it 2n, 2n-1, or 2n-2? Answer: When the samples are derived from bivariate normal coordinates where we have to estimate the center we give up two degrees, so the Gaussian correction term which is calculated with 2n+1 for a pure Rayleigh sample should be run with 2n-1, and the estimate itself is a chi-squared variate with 2n-2 degrees of freedom. How can I be certain I got that right?

This is one of the great things about fast computers and good (pseudo-) random number generators: We can actually resort to fundamental definitions and run simulations to verify statistical formulas. The definition of an x% Confidence Interval is a range of values that contains the true parameter in exactly x% of experiments. In the real world cases we care about we generally do not know the true parameter of a random variable with certainty. But when I programmatically generate a random number I know exactly what the parameter is, because I have to specify it. So with a random number generator we can simulate experiments in which we know the true parameter.

In the figure above I have formulas for confidence intervals. Are they correct? Here’s one way to check: I simulate many experiments using the random number generator, and in each experiment I use the formula to calculate a confidence interval. Then I just count how many times the confidence interval contains the true parameter. If my formula is correct, it will match the average I find through repeated experimentation. And the more simulations I run, the closer my average observation comes to the true value. (This is a fundamental theorem of probability called the Law of Large Numbers.) With modern computers I can run this simulation millions of times in a matter of seconds, which is enough to see these numbers converge to 4 or more significant figures.

My GitHub contains Jupyter notebooks where you can see and even re-run the code for these simulations. The statistics here are not extraordinary, and the formulas are widely known. More advanced statistical inference here includes some formulas that I could not find anywhere else.

Muzzle Velocity is Normally Distributed (+Infographic!)

I’m putting together a book with a lot of statistics applied to ballistics and trying to fill it with helpful examples since the pure math is hard to absorb. Below is one infographic I just finished. It’s an analysis of the muzzle velocity I measured shooting a full box of subsonic .22LR. The left column is all 50 measurements, which I then sort into a histogram to illustrate how muzzle velocity is normally distributed.

Environmental Impact?

This Dyson vacuum comes in 3 pounds of packaging. This includes more than a dozen separate elaborately cut-and-folded pieces of corrugated cardboard. (The cutouts mean that the amount of cardboard that was consumed in producing the packaging was even greater.)

Dyson V8 packaging: 3 pounds of cardboard

The packaging also includes the following note (on that black paper in the middle):

To reduce our environmental impact, we’ve moved your full manual online.

I weighed the full printed manuals that came with two other vacuums, and each was just half an ounce. That’s 1% of the weight of the packaging here. From the picture here, does it look like Dyson has gotten the packing cardboard to within 1% of the minimum needed to protect the product during shipment?

I’m beginning to suspect that this “environmental impact” business is a pretext for something else….

How to restore water pressure by removing flow restrictors

Low water pressure used to be something I only experienced visiting third-world countries.  And the rare occasion when an extended power outage prevented water pumps from refilling water towers (e.g., New York City on August 14, 2003).

First world water infrastructure is supposed to deliver potable water at a pressure of 60psi.  Water conservation fanatics came along and thought our 1/2″ pipes and 3/8″ fixtures were delivering too much water to faucets and showers, so they pushed flow restrictors.

When I stay at hotels the showers are often so weak that I wish I had brought a five gallon bucket to shower from (like I did in some areas of Mexico).  Instead I now pack a small wrench to remove the shower head so I can pry out the flow restrictor.

Often the restrictor will be a small plastic disk like this, in which case all you have to do is pull out that black O-ring and regular flow will be restored.

Higher-end restrictors might have more pieces, but they can all be pried out to restore flow.

I was Emptormaven

When I first started this blog in 2006 I called it “Emptormaven” – from Latin emptor (buyer) and maven (specialist) – and I bought and hosted it under the domain name emptormaven.com. I had intended to write about lots of products, but the majority of my posts ended up being about firearms.

By 2020 I was dropping my pseudonym across my online content, so I moved the blog under my david.bookstaber.com domain and set up a 301 redirect for the last year I owned the emptormaven.com domain.

I recently discovered someone else bought the domain name and is hosting gun-related content on it! I guess I had created significant SEO value. So to whoever is using the name now: You’re welcome.

AR-15 buffers, springs, and cyclic rates

Animation of the AR cycle: Gas tapped from the barrel unlocks the bolt and pushes it rearward against a buffer and spring in the stock. During this travel it ejects the empty case and cocks the trigger. The recoil spring pushes the bolt assembly back into battery, and along the way the bolt strips a round from the magazine and pushes it ahead into the chamber.

Here is a good page describing the essential components and design considerations in an AR-15 action. In this post I summarize some research I did focusing on the tail end of the system: The recoil spring and buffer. In order to see exactly what goes on in there I cut a viewport into a buffer tube, clamped rifles into my test fixture, and recorded high-speed video of the action cycling.

Continue reading

Classic Machine Guns

I had the good fortune to meet Kyle Paaren, proprietor of Paaren Firearms, who specializes in rebuilding classic machineguns – often by rewelding demilitarized receivers. Many of these are brilliant pieces of engineering whose reliability and durability were proven in the mass military conflicts of the twentieth century.

I think the MG42 is the most impressive: It shoots full-power .30-caliber ammunition at a rate exceeding 1100 rounds per minute. It uses a roller-locked bolt mechanism that is unlocked by muzzle pressure (captured in its distinctive muzzle device) pushing back on the barrel itself. Its barrel can be changed in under five seconds.

I was allowed to take photos of some of these recent rebuilds.

Continue reading

Understanding Gun Precision

I’ve written a number of posts over the years in which I test the precision of various firearms. Some readers have asked about the particular methodology I use.

When testing guns for accuracy it is common practice to look at the Extreme Spread of a group of 3 or 5 test shots. I will explain why this is a statistically bad measure on a statistically weak sample. Then I will explain why serious shooters and statisticians look instead at some variation of circular error probable (CEP) when assessing precision.

It is easy to fool yourself with Extreme Spread, and it’s even easier to fool others.
Continue reading