But before I give out the formula, one needs to understand the history of canons. See when canons were first used they were handcrafted and thus each canon was unique. The problem with having varying size of barrels, is that you needed to custom-make the canon balls. Now the easiest way to know if the ball was right, other than actually trying it, was to weight it. For example a 5lb ball of lead will always have the same diameter, assuming it is spherical enough. So the canon would be a "five pounder". Now when applying this to shotguns you obviously have to use fractions of a pound: (from wikipedia) "The gauge or bore of the inside diameter of a barrel corresponds with the number of identical solid spheres that can be made from a pound of lead.". So the smaller the barrel, to smaller you have to make the spheres, and so the more you can make with a pound of lead, hence a high gauge. Now as a scale it can be problematic because I assume that since volume varies proportionally to the power of three in respect to the diameter, the relationship is not linear.
here is the formula
(diameter of barrel in mm)= [(6*1lb converted to grams)/(density of lead*gauge*Pi)]^1/3
Now lets get back to needles. (from wikipedia):
"The diameter of the needle is indicated by the needle gauge. Various needle lengths are available for any given gauge. There are a number of systems for gauging needles, including the Stubs Needle Gauge, and the French Catheter Scale. Needles in common medical use range from 7 gauge (the largest) to 33 (the smallest) on the Stubs scale."
"The Stubs system was the first wire gauge recognized as a standard by any country when Great Britain adopted it in 1884. Each gauge increment roughly correlates to multiples of .01 inches, but the system is not truly linear"
now if you're interested in how needles are made, I recommend checking out the Straight Dope:
"The key to syringe making is forming the hollow tube, or cannula. Processes to make small tubes and hollow needles are quite old, and almost always begin by forming a large tube. This large tube is formed by either rolling a sheet of metal into a tube and welding the seam, or by taking a solid billet of metal and boring a hole through the center while the metal is heated (creating "seamless tubing").
This large tube is softened by heating it (called annealing), then drawn through a tool called a die--which in this application of the word is essentially a hardened piece of metal with a small hole. As the tube is drawn through the die it both stretches, increasing the tube length, and shrinks, decreasing the tube diameter. The tube is passed through smaller and smaller dies, continuing to stretch in length and shrink in diameter, until the desired size is reached. The last drawing through the die is often done without heat, therefore cold-working the tube to increase its strength and hardness. Sometimes a stiff piece of wire or a mandrel is placed inside the tube to prevent the walls from collapsing while it is being drawn, but often the process relies on incredibly consistent steel quality and high-tolerance equipment to manufacture cannulae that meet the specifications."