jlm-blog
~jlm

26-Mar-2020

No refuge in the numbers

Filed under: news — jlm @ 20:41

The State of California, like several other states, has applied an unprecedented “shelter in place” directive to its population to stem the spread of SARS-2. This is a huge cost on the psychological well-being of the citizenry, on their human rights of movement and association, and on the economy, in order to avoid incurring even greater costs in lives lost, reduction in health, and the resulting psychological and economic trauma. Now, after over a week of this, has there been any luck at reducing the spread of the disease? I have no real sense one way or the other. So I went and grabbed the data on the number of cases from March 11th onward from the state Department of Public Health and plotted the infection rate (ratio of new cases to prior cases) since then:

plot of California's COVID infection rate

(data is only up to yesterday because the Department publishes a day’s case facts the next day)

I have no idea what to make of this, so I still have no real sense one way or the other whether it is working. The 18th and 19th are weird outliers, but I double-checked the data for the 17th−20th, and if the graph is wrong then the state’s numbers are. I wish I could draw a conclusion from this, but I can’t.

24-Mar-2020

Rotating only one cubie

Filed under: math — jlm @ 22:00

I’ve entertained myself for countless hours with the Rubik’s Cube, but always as kind of a pointless diversion. It’s something to keep my mind occupied, but I’ve never seriously studied it. I’ve built up a lot of intuition, but when it comes to the group theory that the cubes embody, I have nothing to say. One of the bedrock concepts I’d developed from my intuition is that it’s impossible to rotate only one cubie. You can flip two edge cubies (any two), or four or all twelve, but not one or three. Similarly, you can rotate a corner cubie by 120°, but only if you cancel it out by rotating another corner cubie (any of them) by −120°, or rotate two others by 120° as well to add up to a full 360° (and so be equivalent to no rotation). Why is this? My intuitionistic argument is that a single 90° rotation of a face rotates each of the four edge cubies of the face by 90° and the same for the four corner cubies.

Quarter face-turn rotates 4 edge cubies     Quarter face-turn rotates 4 corner cubies

Since each turn rotates the edge cubies by 360° in total and every sequence is a composition of face turns, the “total rotation” of all the edge cubies together is a multiple of 360° and so equivalent to 0, meaning there can only be an even number of 180° edge cubie flips. The corner cubie rotations sum the same way, hence the corner cubie rotations that don’t cancel themselves out must sum to a multiple of 360°. The conclusions are correct: no sequence can do an odd number of edge flips or corner rotations that aren’t equivalent to zero. The argument is however unsound: adding rotations around different axes together willy-nilly like this can (in other contexts) produce complete nonsense — there’s some extra structure in the cube that makes this OK.

Anyway — I’ve “known” for 35 years or so that you cannot rotate a single cubie of the cube, you must also rotate other cubies of its type to cancel it out. But then, semi-recently, I encountered for the first time a “picture cube” where the orientations of all six center cubies had to be right. The first time I scrambled and solved it was fairly easy: first I solved it like the normal cube, and after that it was easy to work out how to rotate one center cubie by 90° and another by −90°. The second time I scrambled and “solved” it I was left with one center cubie upside down and everything else as it should be. And by brain kind of broke. The one center cubie had rotated 180° and everything else was in place. This had to be impossible, you can’t rotate just one cubie, you need to maintain a balance, there has to be another rotation to cancel it out, doesn’t there?!?! I felt like I had taken a number, multiplied and divided it by another number, and gotten a completely new number as a result. Gradually my faculties returned to me, and I thought back to why I thought you can’t have an unbalanced rotation, and it was blatantly obvious why the argument didn’t apply: a face turn rotates only one center cubie, so it does alter the total rotation of all the cubies after all. Each quarter turn preserves the total rotation of the edge and corner cubies, but alters the total rotation of the center cubies by 90°.

It took me about 15 minutes to completely shake off the feeling of unreality and get myself thinking in the paradigm where center cubies can all rotate independently. In another five minutes, it occurred to me that if I double-swapped the opposing edge cubies of one face and double-swapped the opposing corner ones as well, that was equivalent to a 180° face turn except the center cubie wouldn’t be rotated. That let me solve the configuration the cube was in. What about a 90° rotation? Impossible: the parity of the number of face quarter-turns was also the parity of the number of quarter-turns of all the center cubies summed together. So I had a full solution to the picture cube. Playing around with it further, I optimized the double-double-swap into a double-swap of an edge-and-corner-cubie complex and figured that was as far as I could take it. Yet, I’m sure that what’s going to stick with me the most is the eerie sense of irreality of staring at that lone center cubie, a thing that couldn’t be flipped, but was.

22-Mar-2020

Why we need sick-time regulations

Filed under: news, politics — jlm @ 11:00

There’s a terrifying report from the NY Times and affiliates today: With the traditional retail shut-down triggering a big jump in online retail, there’s been a big jump in the workload at the businesses that get the deliveries to the consumers — and the pressure to meet at that workload is causing many employees to come into work despite being sick, even when they’re almost certainly suffering from COVID!

Absent the pandemic, our laissez-faire approach to sick-leave policies has resulted in a race-to-the-bottom and certainly contributed to the spread of traditional casually communicable diseases like the common cold and flu. With the pandemic, here we see that it’s actively undermining our efforts to fight the disease’s spread! Whether it’s the proper remit of government to prevent this race-to-the-bottom is a matter of political philosophy, and this right here is a demonstration of why it’s bad to not have those regulations. Without regulations, businesses won’t enact policies that reduce the spread of diseases, because that’s a social good but not a competitive improvement. Proper government recognizes that its duty to the society it governs includes ensuring that businesses don’t face competitive pressures to act in ways that hurt the greater society. Sick-time regulation is one such case: a uniform and regulated policy would protect society as a whole by reducing the spread of casually communicable diseases, while letting businesses still compete in the matters that are properly their remit like customer service, productivity, and product quality.

Our failure to have socially beneficial sick-time polities has already contributed to the epidemic and continues to do so. But now that we’re here, we need to do more than look back and regret our foolishness and lack of foresight. A responsible government would step in with emergency regulations and keep these employees home, provide unemployment funds while they’re recovering at home instead of getting paid hours at work, shield them from any retaliation for doing the Right Thing by staying at home, and release the pressure to have so many employees on the job by suspending (or at least relaxing) delivery guarantees. If stopping the spread of the virus is important enough to shutdown retail over, it’s important enough to slow shipments over! Is the US government going to take these obvious actions? Time will tell, but my level of trust is low and I believe it will not, and thereby destroy a decent fraction of whatever good the shelter-in-place policies would provide.

21-Mar-2020

Simple Scala puzzle

Filed under: programming — jlm @ 10:46

Who can guess what this tiny* Scala program does?

object O extends App {
    val x = 123456789L
    val y = 0F
    val z = x - (if (true) x else y)
    println(z)
}

(Apparently this mysterious snippet had been going around a while ago, but I only recently encountered a variation.)

Answer: Prints “−3.0”.

Why?

Short answer: The if/else causes x to get promoted to Float, which rounds it up to 123456792.

Long answer after the fold.

(more…)

19-Mar-2020

No thank you, Captain Skid-for-Brains

Filed under: news, science — jlm @ 22:07

What is it with experts and quotes today?

From “How long will Americans be fighting the coronavirus?” by Christina Larson and Michelle R. Smith, AP News:

“The analogy of pumping car brakes on an icy road is what we should be thinking about,” [Michael] Levy said. “You push on the brakes to slow things down, then ease up – but if you skid, you have to pump the brakes again.”

This is clearly someone who has never recovered from a skid by their own actions, because the only way to do so is to regain traction, which means you must release the brakes. Though I should be less irritated than I am at this error, seeing as anti-lock brakes have been required on cars for long enough that people who have now earned doctorates were adolescents learning to drive after the ABS mandate and dropping of manual brake managment from drivers ed. Get off my lawn, Dr. Whippersnapper, there’s a shelter-in-place order in effect!

Thank you Captain Obvious

Filed under: econ, news, politics — jlm @ 17:14

From Jobless claims jump by 70,000 as virus starts to take hold (San Francisco Gate, by Martin Crutsinger via AP):

“The more aggressive coronavirus containment measures imposed in recent days involving the near total shutdown of the retail, leisure and travel sectors in some parts of the country are clearly starting to have a dramatic impact,” said Andrew Hunter, senior U.S. economist at Capital Economics.

Ya think?

18-Mar-2020

What will happen in three weeks

Filed under: science, sfba — jlm @ 20:01

To be a bit more upbeat than my last post… What will happen is the transmission rates of all communicable diseases will drop. We’ll have less colds, less flus. We’ve put the brakes on the spread of germs in general — at least until we go back to normal, and they go back to normal.

17-Mar-2020

Things that aren’t going to happen in three weeks

Filed under: science, sfba — jlm @ 21:07

• The SARS-2 (COVID) virus will burn out.

SARS-2 has demonstrated its ability to linger in populations, so even if the SFBA manages to rid itself of SARS-2, carriers entering the area will restart the local spread.

• There will be effective prophylaxis available.

Vaccines take much, much longer than that to develop, so we’re not going to see one that quickly. If we had a vaccine to SARS-1, there’d be a slim chance that it’d also immunize against SARS-2, but we’re out of luck there.

• Treatment will be substantially better.

Same as above. Treatments tailored specifically to a disease take time to develop and improve. The potential exceptions would be already existing SARS, coronavirus-general, or broad-spectrum antivirals. But if any of those showed significant efficacy against SARS-2, we’d already know about it. So we’re not buying revolutionary improvements in treatment, but incremental ones.

• The shelter-in-place order will be honored.

People are going to get fed up as the days, then weeks, drag by, and even today I saw kids practicing soccer on the Eastshore field.

 

Don’t get me wrong — there are good odds that a vaccine will be developed or that better treatments will arrive, and combining those with natural resistance means there’s a very good chance that the disease will be stopped. But the new treatments and prophylaxis will take longer than three weeks to happen. And sadly, that means this disease is unlikely to be stopped before it sweeps through our population, and a three-week shelter-in-place won’t change that.

17-Feb-2020

Unit tests are not enough

Filed under: programming — jlm @ 20:48

[I wrote this for another blog back in 2011, but it was lost to public view when that blog disappeared. It’s still valid today, though!]

In one of our datastructures, there’s an entry for a 64-bit unique resource identifier. This turned out to be a little too vague a description: Is it an 8-byte array, a 64-bit wide integer, or an instance of a 64-bit UUID class? One of our developers though one thing, and another thought another. No problem, right? The first compile by the one who chose wrong will show the type error. Except we’re using Python, so no type checking until the code runs. Still no problem, because our devs wrote unit tests, so the type error will show up on their first run, right?

Unfortunately, unit tests help not an iota in situations like this. The developer expecting UUID objects writes unit tests which consume UUID objects, and the dev expecting byte arrays writes unit tests which produce byte arrays.

So, integration tests, then? It turns out our devs did these too, verifying that their code integrated with the fancy datastructure class, but this still didn’t catch the mismatch! This is because the datastructure class doesn’t actually do anything with the resource identifier that would trigger a type check: it just accepts it as an entry in a slot when an item is inserted, and gives it out as one of the slot entries when items are looked up, and Python is happy to let an instance of any type pass through unchecked.

It’s only when we plug everything together that this trivial type mismatch shows up. So the moral: Make end-to-end tests early. You need them to turn up even problems as basic as this, and the earlier you find problems, the better.

27-Jan-2020

My name is Mary, and I’m an electraholic

Filed under: humor — mary @ 20:59

Hi, I’m Mary and I’m an electron addict. I’ve been sustainable for 52 days.

I’d like to share my story. I first began to understand the gravity of my problem during the PG&E blackout in late October. For many of my friends it was an inconvenience, but for me it was an intervention. Within the first 24 hours I began to experience cravings. I craved hot coffee, hot water, any water, hot food; light to read by, light to find the bathroom, terrible TV shows, even terrible news. I became irritable, annoyed with my dog, my husband, even our cat just for being alive and invisible in the dark. I was anxious and jittery. How long could they legally turn power off? Where was the PUC when we needed them? Had Cliff repaired the voltage regulator on our generator correctly or were all our motors being ruined? Why did fires still start when power was supposedly shut off? How could we ever escape this dark prison?

Four and a half days I suffered acute withdrawal symptoms, and then, power was restored. I couldn’t wait to start using. I e-mailed. I showered. I washed and watered and cooked. The endorphins flowed. As frail woman I could wash clothes, send my thoughts across miles, provide hot food for my family and bring water to a parched garden with such ease. The electrons were my slaves.

At the end of the day I went to bed exhausted, but not at ease. I clutched the remote, never wanting the sound and light to stop. I fretted about my supply of electrons. I needed to recharge more batteries and stash more water. Another intervention could occur anytime. I ordered a better generator/inverter on Amazon. I emailed Tesla. What I needed was a fourteen thousand dollar wall of batteries. That Tesla wall looked so lovely in the advertisement. All the precious electrons generated by our solar array could be safely stored there.

Still I could not sleep. Thank God for EA. The ad popped up just after I left the Tesla site. I called and my life changed. My wonderful sponsor helped me to let go and trust my higher power. She helped me see how I had harmed the planet and future generations while using. I accepted Mother Nature as my higher power and my sponsor helped me see Mother Nature’s generous hand in the golden persimmons and scarlet pomegranates, the change of seasons and the arrival of an atmospheric river. My sponsor helped me live sustainably.

Still, as I mentioned, I am a fragile woman. My hands tremble at the dimming of the day. I come here with an urgent need for a sponsor. My first sponsor, my beacon of hope and true north, relapsed on Thanksgiving. Her family refused to believe that a solar cooker nestled in the snow could roast a turkey and sadly they were right.

[ This awesome story is by guest blogger Mary Myers.   — JLM ]

Powered by WordPress