Wednesday, December 2, 2020

2020 Alaska Better Elections Initiative

A ballot initiative in Alaska passed in November 2020 changing their election system (and adding a bunch of campaign finance watchdog measures). The new system is a top-four primary (vote for 1, top four go on) followed by a four-way Instant Runoff Vote (IRV) general election. IRV is known flawed and a pick-one vote with more than four choices isn’t good either.

They also included vote-suppressing language where if a voter ranks more than one choice at the same rank their vote is disqualified if that tie becomes their top vote (if you cast a tie for 2nd but your 1st wins, you’re fine, but if your 1st doesn’t win your vote is gone) ([1] p.9 section 15.15.350.e.1). This is unnecessary. It would be trivial to cast a half-vote for each choice of the tie, or to temporarily set aside the tie-ranked ballot which could come back if half of the tie-rank got disqualified in an IRV round.

2022 should show us the system in action.

[1] 2020 Alaska Better Elections Initiative http://www.elections.alaska.gov/petitions/19AKBE/19AKBE-TheBill.pdf


Monday, November 2, 2020

Every Vote Is Sacred

There are Dems in the world

and Republicans

Greens, Libertarians, and then

Those who pick no party at all, and

let's hear from a-all of them


I'm an American

And have been since the day I was born

but lots of folks make their home here

they're keeping the melting-pot warm


You don't have to be a six-footer

You don't have to have a great brain

You don't have to have any clothes on

Americans count all the same

Because


Every vote is sacred

Every vote is great

When we all are vot-ing

we make our shared fate


[children's choir reprise]

Every vote is sacred

Every vote is great

When we all are vot-ing

we make our shared fate


[girl]

Women haven't always

been granted the right

now that we can we should

vote like it's your fight


[children]

Every vote is wanted

Every vote is good

Every vote is needed

from your neighborhood


[mum]

pundits on the TV

talk but do not know

it's up to you to say

how the vote will go


[misc]


Every vote is sacred

Every vote is great

When we all are vot-ing

we make our shared fate


Every vote is useful

Every vote is fine

We need everybody's

Mine!

and mine!

and mine!


Every vote is wanted

Every vote is good

Every vote is needed

from your neighborhoooooood!


Friday, October 23, 2020

Condorcet Cycles Less Than 1 Election in 1000

How often do condorcet cycles happen? Probably less than 1 election in 1000.

I used two voter models to simulate elections.

Unifom random preference model: Each voter gets a preference [0.0..1.0) for each each choice.

Spatial normal random model: Voters and choices exist in N-dimensional space and are distributed on the same normal distribution. Voters prefer choices based on closeness in space.

Both models produce some sort of close election where any choice has the same probability of wining. I think intuitively the uniform random model is less like reality. Real voters don't have independent variables for their preference for different choices but actually choices are likely correlated: Someone voting for a far-left choice is more likely to have a moderate-left choice as their second choice.

I manually ran a handful of trials this morning and got some first immediate patterns.

The uniform random model resulted in 20-30% of votes going to condorcet cycle resolution.

The spatial model resulted in 1 in 1000 or fewer votes going to condorcet cycle resolution.

Simulated election had 1000 or 10000 voters, 5 or 7 choices, and 2 to 7 dimensions. Dimensionality had no consistent effect on likelihood of cycle.

Next work could be to regularize the search on a few parameters and plot the results, but right now I feel pretty good based on the spatial model that I can say that condorcet cycles should be rare. These are artificially close elections. Normal elections will be even less likely to have a cycle.

Test program source:

https://github.com/brianolson/voteutil/blob/master/go/cyclething/cyclething.go

Friday, October 9, 2020

IRV Sucks But US Politics Sucks More

I'm voting for MA Question 2 Ranked Choice Voting. There's more than one kind of Ranked Choice Voting, and it matters, and "Instant Runoff Voting" is just about the worst, but it might help Massachusetts break out of some ways it's stuck in its Democratic Party machine lock-in on local politics. I don't want Charlie Baker or Scott Brown, I want something else and RCV gives us more of a chance. Right now in 2020 we're facing a US Senator election where the real race was in the primary and the general election is a really likely win for the incumbent Democrat Ed Markey (who I think is doing a fine job). But I don't love the D party and don't want to be stuck with it and don't want people on the other side feeling stuck with the R party. Ranked Choice Voting gives us a potential way of stepping outside the two party system, and locally and nationally the two parties are an increasingly vitriolic rotting mess. So, Yes on MA-2 RCV, let's try it, and maybe make it better soon?

Wednesday, September 9, 2020

What I want in a new Software Engineer

 Chatting with a potential new hire, I wrote this, and wanted to share it with the world.

What skills would you be looking for in a new software engineer?

The ability to get stuff done. Concrete working project experience is nice. In my career all the CS theory stuff about data structures is 10% of the job, and sometimes an important 10% and it's good to know that stuff, but being able to apply it is what really matters.

I like to have a live-coding portion of the interview process to make sure that someone isn't all talk and can actually make a computer go. In a 45 minute interview session I give a puzzle that can be aced in 10 minutes, done well in 20, and most people get it within 30 minutes. Then we chat about the design tradeoffs and how it could have been done cleaner for proper code and optimizations and things like that.

Extended ramble

Above was the core point; below is the appendices.

Don't get stuck in one data structure. I've seen people who only program in (javascript, ruby, perl) who think of every problem in terms of a hash/dict object. You should also be comfortable with arrays, multi-dimensional arrays, trees, heaps, linked lists.

You should be able to recursively descend a tree, but also loop over an array. Be able to think about a four level nested for-loop over data. Understand what it would mean to put an if statement at any level of that.

Underlying operations can matter. An SQL lookup is not O(1) just because you don't see what's going on inside.

Well structured code is wisdom. Some people have a talent for it, more likely it will come with time and reading and writing lots of code. I should not expect a junior hire to do this great, and I should try to be a gentle mentor and use my 25 years of experience to say, "it might be better like this..."

Thursday, August 27, 2020

Small Off Grid Solar System

For $175 (or $265 with all the options) you can keep all your gadgets charged. If you're comfortable thinking in volts, amps, and watts it's pretty easy to design your own system.

The Core System

$20 Renology 10A solar charge controller

$55 50 Watt 12V Solar panel (many commodity options)

$70 12350 12V 35AH battery (many commodity options)

$30 excessively heavy M4 power cables

total: $175

Charge controller

The key piece is the charge controller. You can read its manual and it will tell you how to connect all the other pieces. I got a 10 Amp controller, small, cheap, a couple frills, and I am totally happy with the Renology unit I got. Other units look fine too.

Solar Panel

Since this is a solar system let's talk solar panels. If you're looking at the specs of panels a "12V" panel will have an "open-circuit voltage" and "optimum operating voltage" higher than 12 volts (my 12V panel rated those as 23.3V and 19.8V). That's fine, the charge controller knows and will manage this. By having a higher voltage at peak it can deliver 12 volts more of the time at times other than noon or if there's a little cloud or tree shading your panel. My 50 Watt panel claims 2.6 Amps of "short circuit current" and that 2.6 Amps is well below the 10 Amps the charge controller can handle. So far so good. You could choose to go bigger or smaller here, down to a 10 Watt panel or up to a 200 Watt panel.

Battery

I got a good deal on a used 12350 battery but they're about $70 new. They're a pretty established common item and lots of makers will make them just as good. You can also choose to go bigger or smaller on your battery. Depending on what you're planning to run with this system it might be important to get a bigger battery because 12V lead acid batteries are most efficient used slowly. The 35 Amp-Hour rating is true if you use it at 1.75 Amps over 20 hours. 1.75 Amps * 12 Volts is 21 Watts. You can drain the battery faster, but it won't deliver it's rated capacity. If you plan on running 50, 100 or more watts worth of devices you should probably get a bigger battery.

Cables

Solar panels now commonly come with "M4" connectors which are waterproof and pretty simple to hook up. You can buy connectors and cable and put them together, or just buy assembled cables. The cables it was easiest for me to find were scaled for a full house system of 1000 Watts or more, and I'm only doing 50W. Maybe with a little searching you could find something cheaper but good enough.

Powering Your Stuff

Now that you have the power, you want to use it. The charge controller I got has two 5V 2A USB-A sockets built in which is handy, but there's lots more. This is a 12V system, and there's a world of 12V accessories out there. For $5-10 you can get a 12V accessory socket, wire that to your battery directly or the output on the charge controller, and start plugging things into that socket. NiteCore makes battery charger that run off 12V that I charge my rechargeable AA batteries with. EBL makes a AA/AAA charger that runs off USB which is quite handy. For powering my laptop I found a $20 adapter from Philips that plugs into a 12v socket and delivers 60W of USB-PD. My MacBook is plugged in and charging as I write this.

An inverter is the big hammer of making it Just Work. An inverter takes 12V in from the battery and produces 110AC like any wall outlet in your house, almost. Cheap inverters ($20-50) are "modified sine wave" and will do okay at powering things but may be inefficient and won't work with some picky devices. Better inverters are "true sine wave" or "pure sine wave" ($70 and up) and should be more efficient and produce power most like what you get out of any house outlet. Any inverter will have a wattage limit. A typical house outlet is limited to 1500 watts. A hair dryer or kitchen appliance might use that full power, most things will be smaller. Do your research on the devices you care about, and maybe get a kill-a-watt and measure how much power a device actually uses.

Remember that the battery limits your wattage too. If you're using 12V lead-acid batteries you should optimally have 170 Amp-Hours of battery for each 100 watts of power you want to pull from them. I've been pulling 60W out of a 35AH battery and it works for a little while but it's not great. My next system will be bigger and better!

Tuesday, July 14, 2020

2020 RCV: There's more than one way and it matters

“Ranked Choice Voting” (RCV) can be great, but there’s more than one kind and it matters which we choose.
The promise of RCV is no more spoilers, no more splitters, no more ‘throwing your vote away’. If you don’t get your first choice (your honest first choice), you might get your second choice, or third.

But, there’s more than one way to do it. Mathematicians have been debating how to do it for hundreds of years and continue to propose new methods to theorize about. In my reading of the field I think there is a consensus pretty-good option, and consensus that a bunch of other methods proposed over the years have flaws and should be archived as oddities.
To say it in a modern way, if you care about what your news feed shows you or what search results show you or what your credit score or insurance bills are: the algorithm matters. I studied Computer Science and to me an election is an algorithm that turns data (votes) into a decision of who is the winner. Different algorithms pick different winners.

Two Algorithms

Here’s two algorithms, both of which work on a ranked choice ballot, (voting for candidates 1st, 2nd, 3rd, etc.)

1.
For each ballot, add a point for A preferred over B: the 1st choice gets one point against the 2nd choice, 3rd, 4th, and so on; and the 2nd choice gets one point against the 3rd, 4th, etc. If A is preferred over B more than B is preferred over A, we say “A defeats B”. Usually one candidate is undefeated and the winner, but it is possible to have a cycle where A defeats B, B defeats C, and C defeats A. But maybe 1000 people prefer A to B, 999 prefer B to C, and only 990 prefer C to A, then A should be the winner.
2.
Count all the first place votes. If a candidate has more than 50% of the votes, they win. Until there is a winner, disqualifying the lowest scoring candidate and move votes to each ballot’s highest currently active candidate.

The first algorithm was popularized by a French mathematician in the 1700s and is called “Condorcet’s Method” but I like to think of it as a “Virtual Round Robin Tournament” with a contest between every pair of candidates. The second algorithm has been called “Instant Runoff Voting” (IRV) because it holds a pick-one election, but then instantly rearranges the vote for a ‘runoff’ if no candidate got over 50% of the vote.

If more people want A than B, A should win. Let’s call that the ‘majoritarian principle of democracy’. Condorcet’s method is built around it and implements it as best as possible (with its built in tie-breaker details). IRV can fail this. It happened in 2009 in the election of Mayor of Burlington, Vermont; and then they repealed IRV there.

Currently IRV is getting more press than Condorcet. I think this is because it's slightly easier to explain (see the lengths of my paragraphs above), but this simplicity is not a good thing, it's a blind spot. Condorcet considers everyone's whole ballot at once; IRV only considers a tiny part of each ballot; and that leads IRV to make mistakes.

I've written software to implement both and in that sense they're pretty similar in complexity. There is high quality open source software implementing either that should be understandable and verifiable by 90% of the programmers out there. Practically there's no additional cost to implement one or the other. They use the same ballots, and take similar number of words to write down in legalese in a law. But, they get different outcomes, and it can matter.

FAQ

“But will my second choice detract from my first choice?”
Sometimes you vote and you don’t get what you want. That’s true now, it will always be true, but it could be better. If you don’t get your first choice, is your second choice still kinda good? Maybe you really wanted Bernie Sanders but Joe Biden will kinda do (2020 D), or maybe you really wanted Ron Paul but Mitt Romney is kinda good enough (2012 R).

"Aren't there lots of Condorcet cycle-resolution rules?"
Yeah, they're kinda all good-enough. Cycles are rare; times when cycle resolution rules get different answers are even rarer. I've done statistical simulations of millions of elections and simulated voters are happier with the outcome of any Condorcet method by a wide margin over the results of IRV elections.

"Aren't IRV problems rare?"
Yes, but it did happen. And for no additional cost or complexity we could have something better, so we should, right?

"Isn't IRV better than what we have now?"
Yes, but for no additional cost or complexity we could have something better, so we should, right?

One risk of implementing IRV is that it elects the wrong person and then it gets repealed and we go back to pick-one voting. This happened in Burlington, VT. How long does it take for that to fade before we get to try again? Let's not pick the known-flawed system. Let's be smart, it's easy.

Monday, June 1, 2020

Boston Protest, 2020-05-31

I spent a lot of time this morning skimming twitter looking for original video as much as possible. Here's the highlights and mostly lowlights. I'll probably keep adding to this for a while. (2020-06-01 08:46 US/Eastern)

The good

crowd chants "Black Lives Matter" while holding up phone lights
https://twitter.com/dotdotdot_BOOM/status/1267335155561246722

crowd of lights
https://twitter.com/kendratuna/status/1267303158340038656

statehouse crowd
https://twitter.com/MizzAngieV/status/1267329172571148288

mutual applause moment passing Tufts Medical
https://twitter.com/StringerBoston/status/1267244732826161152
another
https://twitter.com/ariellabellaa13/status/1267319136348254208

drumming and chating and phone lights around dusk
https://twitter.com/xietymemes/status/1267326379311411203

And really lots more. Last night I read probably hundreds of positive posts from 6pm to 9pm about the Boston protest as they marched from Nubian Square to the State House.


The bad

BPD smashing their own car windows
https://twitter.com/_fynewyne/status/1267394150212816896
another view
https://twitter.com/mattemattmatte/status/1267316793607061504
counterpoint? this may be earlier video of the same car, and maybe later BPD was trying to clear shattered glass so they could see to drive it away?
https://twitter.com/Nelsonbarros_12/status/1267317955429371904

abandoned police vehicle with white protester jumping on its roof
https://twitter.com/MokhaPapi/status/1267321326949355520

big white dudebro yelling at cops he's gonna fuck them up
https://twitter.com/StringerBoston/status/1267395690612867073
gosh, you come looking for a fight you just might find one

possibly another view of that moment, you can see BPD grabbing a protest sign, and while the protester still holds onto it BPD sprays them
https://twitter.com/jasnguzman/status/1267324984776679424

random boston common teargas hellscape
https://twitter.com/Dnxmb2/status/1267367073908436993

note the bike cop in the lower right spraying people as they run away
https://twitter.com/NicLaschever/status/1267360848269455361

white people vandalizing and crowd calling them out on it
https://twitter.com/ugh_ren/status/1267357678092894208

30+ minute video of a guy wandering the protest teargas hellscape on Boston Common last night (starts at the scene of BPD smashing their own car)
https://youtu.be/QjYJMmShTp0

police/guard line advancing down a street grabs and throws to ground protester who was mirroring their line
https://twitter.com/TobinMary/status/1267355384274182146

street full of military vehicles
https://twitter.com/luciana98214252/status/1267346730720415744

hummers and prison bus rolling in
https://twitter.com/loneIiestplace/status/1267288733881110528

police over unresponsive black man (tweet claims this is just post beating)
https://twitter.com/38swavey/status/1267335929838125056

police line scuffle
https://twitter.com/iza_rey/status/1267330412994576385

scuffle in front of suoffolk law, police car comes in then backs out
https://twitter.com/MokhaPapi/status/1267320194655027200

police line advances on protesters (reports of gas)
https://twitter.com/brenna0326/status/1267290162574372868

the moment the ATT store on Boylston gets opened and looting starts
https://twitter.com/RoyAvieli/status/1267319653908525057

aggressive police line (borrowing some hakka style?) smoke grenade?
https://twitter.com/DrQatherine/status/1267319227725295619

3 BPD cars driving fast through State House protesters
https://twitter.com/Tori_Bedford/status/1267343596753166336
organizers calling a peaceful end to the official protest
https://twitter.com/Tori_Bedford/status/1267262624825331718
police line vs crowd, crow throwing water bottles
https://twitter.com/Tori_Bedford/status/1267266676002820100
people running from pepper spray cloud
https://twitter.com/Tori_Bedford/status/1267266960133443584
things and smoke cans thrown both ways, Tremont St, downtown Boston
https://twitter.com/Tori_Bedford/status/1267266799218888710
smoke clouds on Tremont St, downtown Boston
https://twitter.com/Tori_Bedford/status/1267266909143171073

firework thrown into crowd of cops
https://twitter.com/WCVB/status/1267293105029611521

jewelry store looting
https://twitter.com/WCVB/status/1267276579694149632

crowd runs away from smoke/gas
https://twitter.com/WCVB/status/1267272343455490049

crowd with smoke/gas, can being thrown back
https://twitter.com/WCVB/status/1267266862192234498

BPD pushing the crowd down the street with pepper spray
https://twitter.com/_dasshy_/status/1267306468052799488

"You are ordered ... to (disperse) the area or we will deploy gas"
https://twitter.com/kyliejmariie/status/1267296234177466368

many police in theatre district, one corner out of a windshield
https://twitter.com/_t_13/status/1267303762835668992

BPD car playing chicken with protesters
https://twitter.com/SBolotana/status/1267295787840610305

Irony

closeup of BPD officer with a Bob Marley covid mask
https://twitter.com/iMissbeyhave_/status/1267333872854982663

WGBH radio this morning, "As of today office buildings in Boston are allowed to welcome back workers at limited capacity."

Tuesday, April 28, 2020

A Go http framework less good than the standard library

tl;dr: don't use "Echo" Go web framework.

Bad smell: "guide" documentation only, no "reference"

If you go to the project homepage there are two links that look like big buttons in the middle of the page, "GitHub" and "Get Started". Going to the "Get Started" "Guide" documentation there are lots of examples about how to use APIs, but nothing that explicitly spells out what the function signature is. I want to know exactly what it is and what I can do with it. It shows some methods on an object being used, but there's no reference document for that object listing out all of the things I might do with it. I had to read the source to figure out what the objects were and how to use them.

Bad smell: requires closures instead of interfaces

The Go standard library net/http package defines a Handler interface that passes in two objects, a Request and a ResponseWriter. Someone clever once figured out that you could also just pass a function pointer to this and it could satisfy the interface. Echo doesn't define interfaces but only function signatures. Thus it requires that any state be held in closures instead of structs. The net/http way allows for closures or structs. Requiring closures might be fine for Haskell or Scala but is bad Go style. The project I was working with which had adopted Echo had some triply nested closures to set up the functions that Echo would call. It was hard to tell exactly what scope was being captured to run each closure. A struct implementing an interface explicitly and clearly declares what values it needs to run. Clear simple explicit code that is easy to read and understand is the go way.

Wednesday, March 4, 2020

National Primary Compromise: RCV, many voting days, one counting day

There's lots of debate about how to structure the presidential primary. Maybe a few small states should go first because 'retail politics' is valuable, but maybe it should be different states sometimes. Maybe states should be grouped into regional blocks and rotate off which region goes first every four years. Maybe we should have one national primary on one day so no one goes first or last and everyone gets an equal vote. And whatever the schedule, we should vote on Ranked Choice Voting ballots so there's no 'spoilers' or 'throwing your vote away' and people can honestly say who they like first, second, and third, and so on.

Personally I favor one national primary day. US President is the one thing that everyone in the US can vote on and we should all do it together. No one should go first or last.

But I'd like to propose an odd compromise: Many voting days, one counting day. We can have exactly the same schedule we have now or any schedule. Everyone votes when their state comes around, but then all the ballots (RCV) go into one big pot. We still get retail politics, we still get an extended campaign where candidates talk to more voters, but late voters can still potentially cast an honest rankings ballot that's more complex than the decision many people are forced to make now of voting for their honest favorite or a less preferred candidate that seems to be winning. No splitters, no spoilers, but still mostly the familiar system we have now. When all the votes are cast, count all the ballots in one big RCV process to pick a winner.

I would prefer if the votes were secret until the last vote was cast, but that's not necessary. Revealing votes early will cause some bandwagon effects, but people can still vote honestly that they like someone else better even if the bandwagon doesn't seem to be going that way.

This has a sneaky side effect: direct election with no delegates and no convention. We had a vote and there's a decision. I guess there could still be a convention, maybe have a one night media event where we rally around the winner. I think most people don't want 5 days of boring speeches of politicians talking to each other.

So, that's my idea:
National RCV Primary: Many voting days; One counting day
I'd still rather rally around
One National Primary Day on Rankings Ballots
but what do you think? Workable compromise worth doing or go big for the full reform?

Sunday, February 2, 2020

Another Stupid Election Year

I feel frustrated and angry as this country blunders at full speed through another stupid election process.
3.1 million people in Iowa get to go first, ahead of everyone else, setting the trend, making the bandwagon for people to follow on to. But in 2016, 171,517 people actually showed up. 171,517 people with some blessed status to have the most important votes in the country. And not for any good reason, but through accident of a bunch of crappy reasons.
And then three other states get to go, and then finally on March 3 about a third of the country gets to vote, and two thirds of the country has to wait and watch and wonder if they get to have any say when the vote finally comes around to them.
And I'm angry that the system is so stupid and wrong when the right answer is so obvious. For the one office voted on by everyone in the country, president of the UNITED STATES, maybe the whole UNITED STATES should vote, all as one?
And it's long past time for the ELECTORAL COLLEGE to be scrapped. Either we should have a REAL DIRECT ELECTION (my preference) or we should stop pretending and just have a parliamentary style system and the House can elect a President.
And people who pay attention to such things have known for decades (possibly centuries) that pick-one ballots are stupid and inferior and being able to rank your choices on the ballot opens up a world of possibility of BETTER ELECTION RESULTS. Better ballots result in better decision making and better results.
I'm angry that the system is stupid when better solutions cost almost nothing and are trivially knowable.