Speaking of the math, would you mind giving the formula you used to calculate the range of +/-’s?
Here’s the MATLAB code I wrote, although for looking at your recent posts, the numbers were small enough that it wasn’t necessary to run this, e.g. +1 and 67% has to be +2-1.
For those who know programming but not MATLAB, the code should mostly be clear. The line “a = (ceil(a2):floor(a1))’;” sets a to a column vector of every integer between the two bounds, and all subsequent lines are operations on entire vectors at once. “[b,a,a+b]” is a matrix of three columns: b, a, and a+b.
function v = lwvotes( net, frac )
%v = lwvotes( net, frac )
% Calculate votes for and against, given upvotes as both
% net difference and fraction positive. frac can be expressed
% as a proportion or a percentage.
if frac > 1
frac = frac/100;
end
neg = net < 0;
if neg
net = -net;
frac = 1-frac;
end
frac1 = frac-0.005;
frac2 = frac+0.005;
a1 = net/(2-1/frac1);
a2 = net/(2-1/frac2);
a = (ceil(a2):floor(a1))';
b = a-net;
if neg
v = [b,a,a+b];
else
v = [a,b,a+b];
end
end
Here’s the MATLAB code I wrote, although for looking at your recent posts, the numbers were small enough that it wasn’t necessary to run this, e.g. +1 and 67% has to be +2-1.
For those who know programming but not MATLAB, the code should mostly be clear. The line “a = (ceil(a2):floor(a1))’;” sets a to a column vector of every integer between the two bounds, and all subsequent lines are operations on entire vectors at once. “[b,a,a+b]” is a matrix of three columns: b, a, and a+b.