Dealing with x-bar (x̄) and p-hat (p̂) in Statistics


Revised Oct 23, 2012

A common question I get (at least common in Unicode terms) is what the code is for the p-hat (p̂) symbol and x-bar (x̄) symbols in statistics. Although these are common symbols, they haven't made it as a single character into Unicode (much like there thermodynamic dot symbols are half missing unless they are also in Old Irish or another foreign language's spelling system.

The good news is that they can be created in Unicode, but it's quirky. The trick here is to forget math and think phonetics. There is a mechanism to place any diacritic/accent mark over any letter using one of the combining diacritics These are accents, but with a spacing specification that basically says to go backwards over the previous letter.

There's a list of various combing diacritics for HTML at our sister site, Penn State Computing with Accents Diacritics page, but I'll explain how it works for x̄ and p̂


For HTML, I recommend inputting the base letter (x or p) then the appropriate numeric escape code for the combining diacritic. See code examples below:

View the HTML Code

x-bar = x̄ or x̄ (hex)

p-hat = x̂ or x̂ (hex)

View Results

x-bar = x̄ or x̄ (hex)

p-hat = p̂ or p̂ (hex)

Font Notes

If the result of your code is something like p^or ^p rather than , the problem is usually the font. Relatively few fonts support combining diacritics well (not even math fonts support diacritics well). Those that do are phonetics oriented and these include include:

The first two fonts come from Microsoft/Apple, are commonly installed, and also include math symbols...but they are sans-serif fonts. If you want a serif font, you may want to specify one of the other serif phonetics fonts, then point users to it (but specify Arial Unicode/Lucida Grande as backups). Not a very pretty solution at the moment.

Word, etc

And now the fun really begins. You can input these characters in other programs (see below), but editing them will be odd (see below). Here's the procedure:

  1. Switch to a font which supports combining diacritics and type the base letter (x or p in this case).
  2. Type a space and move your cursor back (you'll thank me for this tip):
  3. Then you can insert the combining diacritic:
    1. With the Character Map (Windows) or Character Palette (Mac) OR:
    2. With an Alt code in Word for Windows or an Option code on the Mac Hex keyboard. See codes at The Word/Windows ALT code for x̄ x ALT+0772. The Option Hex code for on the Mac x Option+0304

When you edit, you will discover that sometimes you will delete the accent, and sometimes you will delete the letter beneath the accent (very entertaining). You may need to undo your delete move your cursor with your arrow keys when that happens. It doesn't always look like the cursor is moving, but it is in Unicode text land. When you are trying to type a nasalized open-o /ɔ̃/, you do get some practice....

About The Blog

I am a Penn State technology specialist with a degree in linguistics and have maintained the Penn State Computing with Accents page since 2000.

See Elizabeth Pyatt's Homepage ( for a profile.


The standard commenting utility has been disabled due to hungry spam. If you have a comment, please feel free to drop me a line at (

Powered by Movable Type Pro

Recent Comments