code.swankyquant.color_distance_weight
Compare how close a match it would be if we added our color(weighted) to a bucket.
Each bucket is 5 doubles and contains an rgba accumulator in [0][1][2][3] and a number of samples in [5] Doubles must be used rather than floats or we will encounter number overflow for images that are larger than 256x256 pixels.
(A float or int version for smaller images might be worthwhile.)
The weight should be a natural 1.0 but since we want to encourage early bucket jumping we fudge it high at the start and then lower it on later passes to bring stability to the feedback system. This is simply to reduce the number of passes over the data required to get good results.
This function also accounts for most of the thinking time so could/should be optimised more.