All this data is potentially out of date, and should be taken with a truckload of salt
The raw formula
ChanceToHit = 0.5 ^ ((((Transversal speed/(Range to target * Turret Tracking))*(Turret Signature Resolution / Target Signature Radius))^2) + ((max(0, Range To Target - Turret Optimal Range))/Turret Falloff)^2)
Note: max(a,b) is a function that returns the greater of two values.
Note that ChanceToHit is a number between 0 and 1, and is primarly determined by Transversal Speed and Range To Target.
EVE tests ChanceToHit for each individual shot made by a gun turret against X, where X is a random number also between 0 and 1, e.g. 0.765321, generated by the EVE server for each shot.
If X < ChanceToHit, the shot is a hit. If X > ChanceToHit, the shot is a miss or zero damage is applied.
X also determines the quality of a hit. If X < 0.01, then the Quality Of Hit multiplier = 3. (i.e. a 'Wrecking' shot) If X > 0.01 the Quality Of Hit multiplier = X + 0.5
ChanceToHit, essentially, specifies an interval in which values of X can fall that qualify or disqualify a hit. The larger this interval, the larger the values X can take, and hence the larger the hit multiplier (i.e. X + 0.5) can be.
For example: A shot with ChanceToHit = 0.97 X = 0.980, the shot misses. X = 0.541, the shot hits, with a damage multiplier= 1.041. X = 0.001, the shot hits, 'wrecking' with damage multiplier = 3.
What are each of the terms used ?
Transversal speed is the absolute speed (in meters/second) at which you and your target are moving in a plane perpendicular to the line joining your ship center to the center of the target. In short, transversal velocity is the velocity component that changes the angle to your target. Two ships chasing each other in a straight line or heading straight at each other would have this number be zero. The smaller this number, the better your chance to hit will be.
Range to target is the distance (in meters) between your ship's outer boundary box to your target's outer boundary box. Two similar-sized ships that are bumping each other, or a smaller ship very close to a station (or a much larger ship) would have this number be zero. It is notewhorthy that depending on circumstances, a smaller range to target could mean a better chance to hit, or a worse chance to hit.
Turret Tracking is a number qualifying your gun turret's ability to track targets (in radians/second). The larger the number, the better your chance to hit will be.
Turret Signature Resolution is a number qualifying the originally intended target size (in meters) of your gun turret. The smaller the number, the better your chance to hit will be.
Target Signature radius (in meters) should be self-explanatory. The larger your target, the better your chance to hit will be.
Turret Optimal Range (in meters) is the rated range of your gun turret for a 100% chance to hit against a huge, immobile target.
Turret Falloff (in meters) is the distance past your turret's optimal range where the chance to hit against a huge immobile target drops to 50%.
Base Damage is a number that shows how much damage a normal shot is expected to inflict. The number is equal to the sum of damage numbers on the ammo, multiplied by the gun turret's damage multiplier (listed in the turret's showinfo window).
The higher quality hits get discarded as the hit chance gets smaller. That means the average DPS decrease more sharply as hit chance decreases to 50%, and decreases less sharply thereafter (i.e. as a square function, not linearly).
It also means that at or below exactly 1% hit chance, ONLY wrecking shots hit, for a grand total of 3% from the "expected average" DPS, even if your hit chance is barely 1%.
A 50% hit chance would mean 1% wrecking hits, and 49% normal hits evenly distributed in the damage multiplier range of 0.51 to 1.00, for a final DPS of a bit under 40% instead of the "expected" ~52% DPS.
Simplified form for average DPS for chance to hit at or ABOVE 1%: AvgDPS = Base Damage * [ ( ChanceToHit^2 + ChanceToHit + 0.0499 ) / 2 ] Simplified form for average DPS for chance to hit at or BELOW 1%: AvgDPS = Base Damage * 3 * ChanceToHit
This graph shows the expected average DPS (including wrecking hits) as it varies with tracking or falloff: