Performed some experiments on an unarmored, clothes-only human in adventure mode, then had him put on some armor and tested again.
Results:
1) The minimal height required for the bug to work is two Z-levels. It does not require the test subject to wear armor or clothes.
2) Falling two Z-levels onto one spear yields 148250 experience for each skill, two spears: 296490. Falling three Z-levels onto one spear: 546440, two spears: 1092880. The experience gain might fluctuate slightly, but often remains stable.
3) Skill level does not influence experience gain.
4) Falling two Z-levels onto one spear while wielding two weapons of the same skill yields 296490 experience.
5) There is no difference in experience gain between wooden training spears and silver spears, or between well-made spears and exceptional spears.
6) It is possible to become Legendary from No Skill. In such an event, experience gained is always one thousand higher than it is in any other case. And I mean always: it does not change regardless of how many weapons of that skill you hold, the height from which you fall, the amount of spears you fall onto. Wait, no, I was calculating it wrong. No 1000 experience points here, just a mistake on my part.
7) Falling with three lead bins, two lead crutches and one lead splint on me, which added 578lb to my weight, did not yield any extra experience.
8) Changing humans' BODY_SIZE from 4000 to 400000 did not result in higher experience gain.
9) My attributes remained constant no matter how many skill levels I gained.
10) My Armor User skill did not increase even in armor.
Conclusions:
1) Experience gained is proportional to the amount of spears you land onto. It is also proportional to the amount of weapons of a given skill that you currently wield.
2) Experience gained is not proportional to the height from which you fall. (Unfortunately, I don't have enough data to determine how the two are connected.) Still, I can't help but notice that falling from one more Z-level yields a significantly bigger increase in experience than falling onto one more spear.
3) Leveling up from No Skill has a weird tendency to grant one thousand more experience than leveling up from any other experience level is possible and behaves exactly the same as leveling up from any skill level.
4) Weight does not influence experience gain. Body size does not influence experience gain.
5) Experience gain from this bug does not increase one's attributes.
UPD:
Testing with a higher stairway and ten spears:
1 Z-level - no skill gain, "the spinning cacao wood training spear misses you!" x10.
2 Z-levels - 0/700 Adequate -> 13955/17200 Legendary+147, total of 1482455 experience points; 0/500 No Skill -> 12850/17200 Legendary+147, total of 1482455 experience points. Fits the prediction based on previous experiments: 10*148250 ≈ 1482455.
3 Z-levels - 0/700 -> 5096/33100, total 5464496, 0/0 -> 3996/33100, total 5465496. Fits the prediction: 10*546440 ≈ 5464496.
4 Z-levels - same as 1Z, those spears just keep missing me.
5 Z-levels - same.
6 Z-levels - same.
7 Z-levels - same.
8 Z-levels - 0/700 -> 26537/32100, 5160436 points; 0/500 -> 25537/32100, 5160436 points.
9 Z-levels - 26537/32100 -> 11363/35200, 1026426 points; 0/700 -> 13263/14300, 1026426 points.
10 Z-levels - same as 1Z.
11 Z-levels - same.
Repeating the experiments with different races and different quantities of spears shows the same pattern.
What we learned:
1) There is no obvious correlation between falling distance and experience gain. The most likely explanation is that the figures the game ends up working with are so ridiculously high that they repeatedly enter stack overflow; levels 2-3 and 8-9 are just sweet spots where the end value is positive for whatever is responsible for checking whether the spears hit you.
2) The highest experience gain you can achieve is with a 3 Z-level fall onto ten spears.
3) Upright spears can't hit you if you fall at them from the right height. The fall will probably kill you anyway, but that's beside the point. Point, geddit?
What we could do next:
Perform experiments with 2, 3, 4, 8, 9 Z-level falls in Fortress Mode, look up in combat logs whether they get hit by spears at Z-level 4, see how their skills change via DFHack or Dwarf Therapist, upload the results here. We'll find out if Fortress Mode calculations work the same way.