Entropic Thoughts logo

Entropic Thoughts

Subscribe
Archives
October 23, 2024

Watching out for false positives, folding left and right

We do a little basic Bayesian analysis to determine in advance how to react to difficult real-world situations.

I hope your week is going well!

New articles

Incident Inference From Symptoms

False positives are a part of any detection mechanism, and if false positives are common enough compared to the actual problem, it might be prudent to ignore apparent signal. But what if we are in a situation where the risk of problem is heightened? We'll see!

Full article (5–10 minute read): Incident Inference From Symptoms

Flashcard of the week

I have had a few very busy weeks, and I'm falling behind on my flashcards (the backlog is 300-something repetitions at the moment, but at least it's not growing). This week I will pick a flashcard that I haven't actually yet repeated, but composed yesterday!

Which fold is foldr, and which is foldl?

I always get these two mixed up, especially when it comes to when which is appropriate and the order of the arguments of the combination function passed into them.

foldr = f x (foldr f e xs) whereas foldl = foldl f (f e x) xs

In other words,

  • foldr runs the combination function on the current element and the recursive foldr call, whereas
  • foldl updates the initial value with the operation performed on the current element and the previous initial value.

An imperative programmer may want to think of foldl as a foreach loop: given some starting state, it runs the loop body once for each value in the iterable, and then updates the loop state with whatever value is returned from the loop body.

It's harder to find an analogue of foldr in imperative-land, but one can almost think of it as the same thing, only running the loop backwards: starting with the last element of the list first, and then working one's way forward. The reason this is not a perfect analogy is that foldr is short-circuiting, meaning if at any point it determines that it won't need the earlier iterations (performed on the later parts of the iterable!), it never performs them.

Your opinions

As always, I cannot improve without feedback. Reply to this email to share your thoughts on any of the topics above, or anything else!

Don't miss what's next. Subscribe to Entropic Thoughts:
custom
This email brought to you by Buttondown, the easiest way to start and grow your newsletter.