Unless PCB has changed it in the latest version, this should all be correct:
If your stat is 17 or below, stat increases are +1 with a 25% chance to get a lucky +2 instead.
If your stat is at least 18/00, it increases by an amount proportional to the difference between your current stat and your potential maximum. Specifically, each increase will be a random value between 20% and 35% of that difference.
Your character's potential maximum is also randomized for each stat, and may be as high as 18/130 or as low as 18/70. Drink a potion of self knowledge to find what it is, or get a rough estimate simply by counting how much you get out of stat potions.
A very lucky PC may have 130 max strength and get the max roll (35%), and go right from 18/00 to 18/45 strength on his first stat increase.
A very unlucky PC may have 18/70 max strength and get the min roll, and thus only go from 18/00 to 18/14.
If they were both at 18/60, the highpotential character would get between 14 and 24 points from drinking another potion of strength, while the lowpotential character would only get 2 to 3 points since 18/60 is so close to his potential maximum of 18/70.
So your stat gains are affected by your stat potentials (which are randomized for every PC), and they are also affected by how high the stat already is  lower stats get the best gains.
Different classes do not get different stat increases, but different characters will have different potentials. Your wizard will have different stat increases from your warrior, but your second warrior will also have different stat increases from your first warrior.
