Archive for June, 2020

Free Printable PD (Pupillary Distance) Ruler

Monday, June 22nd, 2020

Scroll down for printing and usage instructions. Scroll to the bottom for usage disclaimer. Read on from the top for the story behind the ruler:

Click here to download the PDF Pupillary Distance ruler

Click here to download the printable PD ruler (includes instructions) (PDF)

Last year, I was looking for a new pair of glasses, and I decided I’d try ordering glasses online. But besides entering in my vision prescription, I also needed to provide my Pupillary Distance (PD) measurement, which is the distance in millimeters between the centers of the pupils of your eyes. But I wasn’t quite sure what to enter, as I had gotten slightly conflicting numbers from different optometrists in the past. I was also helping a couple relatives who similarly wanted to order glasses online, and they didn’t have any information for the PD measurement on their prescriptions at all! So I needed a way to find the measurement.

I found that online glasses providers have available PD rulers that anyone can download, print, and with the help of a friend or a mirror actually find their PD number. I tried a couple different PD rulers, but I wasn’t completely satisfied with them. One was useful for getting a single PD reading but couldn’t help with getting a more precise value for each eye, another was meant for getting the dual PD reading (the separate value for each eye between the center of the pupil to the vertical center of the face) but it was hard to actually read the measurement and didn’t feel well positioned. Not satisfied with the other rulers, I decided I could take my graphic design skills and do one better.

Using what I had learned from our various efforts at getting an accurate PD number and noticing where the other rulers felt less user friendly, I went into Inkscape, my vector illustration program of choice, and made my own. After a few iterations, I had a ruler which I was happy with, we got our PD numbers, and we ordered our glasses.

Recently, going through my old work, I thought that these days, a lot of people might feel less comfortable going to shop for new glasses in stores, and so this PD ruler I had already created might be of use to more people. And so I prepared it in a format and with instructions for anyone to use, and so I am sharing it here, a free, downloadable, printable, PD ruler! (And later, this tool was updated in December 2020 with alternate nose cutouts on the second, lower, ruler to ensure it will work better for a variety of faces!)

If you would like to offer any feedback or request any changes to it, feel free to leave a comment, and I’ll see if I can tweak it or make a customized version for you. Usage instructions continue below.


Help Keep This Free

To interrupt this post with a quick request, if you find this PD ruler useful, please consider taking a moment and making a donation using the PayPal Donate button below to allow me to continue providing and maintaining free projects like this. Thank you! (Usage instructions continue below.)


To use the ruler, you will need a printer, paper (thicker paper works best), and scissors to cut out the ruler. Click here to download the PDF of the ruler, and print it at 100% scale on US Letter paper (8.5 by 11 inches). Use another ruler that can measure in millimeters to compare it to the printed version and ensure that it matches perfectly. Then simply follow the instructions on the PDF on how to prepare and use the ruler. When you use it, be sure to hold the paper straight and not bend it against your forehead, as that may skew the results. For best results, measure your PD multiple times and with different methods to minimize the chance of inaccurate results. I’d also encourage you to try other PD rulers and find other online guides and videos to help demonstrate how to properly use a PD ruler.

Note that a PD number can be expressed either as a binocular Single PD (total distance between centers of pupils) or as a monocular Dual PD (a separate value for each eye between the center of the pupil to the center between your eyes, which can also be added together to equal the Single PD). When buying glasses, you may be required to enter either your Single or Dual PD. This ruler is a free tool to measure your PD, with instructions for measuring your Distance PD (your PD when looking at a distant object, which is a few mm larger than when you are looking at a close-up object), both for a Single PD and for a Dual PD, whether measured in a mirror or with the assistance of a friend. Your Distance PD is the proper number to use for a distance vision prescription. However, if you need your PD number for a close-up vision prescription, the PD number for that would be a few millimeters lower than your Distance PD. E.g., if your distance single-PD is 60, your close-up PD may be 56 or 57.

Although the PDF has the instructions listed on it, I’ll also provide them here:

To prepare this ruler, print this at 100% scale on US Letter paper (8.5 by 11 inches). (Thicker card stock paper will produced better results.) Ensure it was printed at the proper scale by comparing this PD ruler with another ruler measured in millimeters. Then cut the perimeter of one of the two PD rulers below along the dotted outer line. Fold on the horizontal center line. (Double-sided tape or glue will help the ruler stay flat and stable.) If the ruler sits too high or low on the face to get a good reading on the Dual PD side, try using one of the alternate higher or lower nose cutouts—indicated in light gray on the second ruler—for a better fit.

To measure Single PD, begin by holding PD ruler flat against your forehead with the Single PD ruler side down, just above your pupils.

Method 1 (using a mirror): Standing in front of a mirror with the PD ruler in place, close your right eye, and align the 0mm marker over the center of your left pupil. Then, without moving the ruler, open your right eye, close your left eye, and see which point is above the center of your right pupil. This is your Single PD, in millimeters.

Method 2 (using an assistant): With assistant holding PD ruler in place, assistant should face you squarely and close their right eye. With you looking at assistant’s open eye, assistant should align the 0mm marker over the center of your right pupil. Assistant should then open their right eye and close their left eye, and with you looking at assistant’s open eye, assistant should see which point is above the center of your left pupil. This is your Single PD.

To measure Dual PD, begin by placing the PD ruler flat against your forehead, resting it centered on the bridge of your nose, with the Dual PD side down, and your pupils visible under the L (left) and R (right) eye cutouts.

Method 1 (using a mirror): Standing in front of a mirror looking straight on, with PD ruler in place, close your right eye and note which point is above the center of your left pupil. This is your left eye PD, in millimeters. Repeat, with your left eye closed and right eye open, for the PD of your right eye.

Method 2 (using an assistant): With assistant looking squarely at you and holding PD ruler in place, assistant should close their right eye. With you looking at assistant’s open eye, assistant should note which point is above the center of your right pupil. This is the PD for your right eye. Assistant should repeat the process, with their left eye closed and right eye open, for the PD of your left eye.

Note: Getting an accurate Dual PD reading may be more challenging than a Single PD. You must be especially careful to look at the mirror or your assistant perfectly straight on with no rotation of your face so the proper point on the ruler will visually align with your pupil.

Disclaimer: This PD ruler tool was made as a personal project. This ruler and its associated information and instructions were not produced by vision professionals. The information and instructions provided here and on the PD (Pupillary Distance) ruler is not intended to be medical or vision advice. Consult your vision specialist for help in determining what information you need relating to your PD number and how you should determine your PD measurement(s). This tool is provided without warranty. Like any printable PD ruler, this may not produce results as accurately as can be measured by a vision professional. User assumes all responsibility for use of this ruler.

Announcing a New, Free, Online App: Bayesian Probability Calculator

Wednesday, June 3rd, 2020

Bayesian Calculator icon Announcing a new project I just completed, a Bayesian probability calculator! This is a personal project I began in 2018 and have recently revisited, improved, and finished up. I took an interest in Bayesian probability (learn about Bayes’ theorem here at some years ago when I recognized how powerful of a tool it is to, basically, help calculate how likely things are to be true (based on the information that you have available). It’s all about taking your prior belief (or the “prior probability” as some value between 0% and 100%) about whether some idea or hypothesis is true, and when you come across some new evidence relating to it, revising the belief by properly factoring in the evidence through considering how expected it was assuming the hypothesis is true and how expected it was assuming the hypothesis isn’t true. It’s not too different from how people might generally take new information into account for informing their beliefs, but Bayes’ theorem frames the question precisely, reminding us to pay attention to false positives and our prior beliefs. So by applying Bayes’ theorem, when we make some new observation, we can consider how expected that observation would be if our prior belief was true and how expected it would be if it wasn’t true, and we can consider that given what we previously thought the chance was for it to be true.

The equation itself looks like P(H|E) = [P(H) × P(E|H)] / [P(H) × P(E|H) + P(¬H) × P(E|¬H)], which means that the probability that a belief is true given new evidence (P(H|E)) can be calculated by multiplying the prior probability for the hypothesis by the expectation for the evidence given the hypothesis (P(H) × P(E|H)), divided by the total expectation for that observation, which is itself the prior probability times the likelihood for the evidence given the hypothesis plus the prior belief that the hypothesis was wrong times the expectation for the evidence given that the hypothesis was wrong (P(H) × P(E|H) + P(¬H) × P(E|¬H)). For a great and intuitive explanation of exactly why this works, I recommend this wonderful video by 3Blue1Brown on YouTube.

To give a simple example of Bayes’ theorem in action, let’s say you’re wondering whether your new friend shares your passion for geology (but you don’t want to, you know, actually ask). “My friend loves geology” may be your hypothesis. And let’s say you initially don’t think it’s very likely to be the case; maybe you think only 20% of people like geology as much as you. So 20% is your prior probability. But then you hear your friend make a geology pun! (“You know, it’s important not to take all igneous rocks for granite!”) Hearing that, you’ll probably automatically think it’s more likely that they do love geology, but how much more likely? In comes the handy Bayesian reasoning, allowing you to take into account the proportion of geology fans who would make a pun like that and the proportion of non-fans who would, in the context of how many people are or aren’t geology fans in the first place. Simply multiply the percent of geology fans (20%) by the percent of geology fans who would make such a pun, which maybe you’ll estimate that at about 80% (since they love their puns!), giving you 16%. Then multiply the percent of non-fans (80%) by the percent of non-fans who would make the pun, which maybe you’ll estimate that at about 10%, giving you 8%. That original 20% vs 80% population split now is whittled down by those who tell puns to become 16% (geology fans) vs 8% (non-fans). With that, you can intuitively recognize now that it’s twice as likely that your friend is a geology fan than that they aren’t. Putting the numbers into the final form of the equation, you can see that the probability is 0.16/(0.16+0.8), which, based on those assumptions, equals a 66.7% chance that your friend loves geology as much as you do.

Bayes’ theorem can be useful when intuitively applied, but I wanted to make a tool that would allow me to quickly and easily calculate exact probabilities. After all, plugging and chugging the numbers into an exact equation like P(H|E) = [P(H) × P(E|H)] / [P(H) × P(E|H) + P(¬H) × P(E|¬H)] can be cumbersome. When searching, I found that there were some other Bayesian calculators online, but I felt that they were limited in how much input could be made, or how intuitive they were to use, or how fast they worked. So I set out to create a tool where I could easily calculate probabilities and add multiple pieces of evidence and tweak values, with instant results at every change. Hence, my Bayesian Calculator for Updating Probability with Multiple Conditionally Independent Variables.

Link to this entry on my portfolio:

Bayesian Calculator

I originally designed the calculator to apply the basic arithmetic of Bayes’ theorem with the standard JavaScript operators, where additional pieces of evidence could be added with ease, where the operation would be able to simply repeat itself, taking the posterior probability from the results of the first evidence to become the new prior for the next, which is perfectly valid, as long as each piece of evidence is distinct. Since it operated on client-side JavaScript, all the math could happen instantly, without having to wait for the inputs to be processed by a web server. I packaged it in an HTML5 webpage with CSS3 styling to have a responsive design that works well across platforms, and I added explanatory text and instructions for anyone else who might want to use the calculator. As I continued to experiment with it and develop it and work on debugging and find any areas that may lead to errors and require custom alert messages, I also observed that there could be certain (albeit pretty rare) inputs that have too many decimal places for JavaScript to properly handle, so I then incorporated the Big.js JavaScript library to perform the math and work with larger numbers of decimal places. Most recently, I added something called the Bayes’ factor to the outputted results, which rather than telling you a final probability which is dependent on your own prior probability input, the Bayes’ factor also tells you how significant the evidence itself is.

When I was satisfied that the calculator was working well and could be a fun and useful tool for others, I finally set it up to be published and accessible online. Check out the Bayesian calculator here!