Programming Leftovers
-
Lánczos interpolation explained
Lánczos interpolation is one of the most popular methods to resize images, together with linear and cubic interpolation. I’ve spent a lot of time staring at images resampled with Lánczos, and a few years ago, I wondered where it came from. While many sources evaluate interpolation filters visually, I couldn’t find a good explanation of how Lánczos interpolation is derived. So here it is!
In this post I do not attempt to explain what a Fourier transform does, so if you do not know that already you might find the mathematical details unclear. However, I do try to visualize and explain the intuition behind all the ideas.1
-
[Old] So you're using a weird language
Looking through Bozhidar Batsov notate his first impressions of OCaml and him previously asking its users about their workflows after finding its REPL/interactivity story more limited than Clojure, I realised I have some experience with the statement "I'm gonna write a program using a weird language," I thought I'd write a few narratives and strategies.
-
Future Proofing SQL with Carefully Placed Errors
Backward compatibility is straightforward. You have full control over new code and you have full knowledge of past data and APIs. Forward compatibility is more challenging. You have full control over new code, but you don't know how data is going to change in the future, and what types of API you're going to have to support.
There are many best practices for maintaining backward and forward compatibility in application code, but it's not very commonly mentioned in relation to SQL. SQL is used to produce critical business information for applications and decision-making, so there's no reason it shouldn't benefit from similar practices.
In this article, I present one simple way to future-proof SQL.
-
More Cores For Mesa llvmpipe
While various alternatives like Libre-SoC continue development, the only 3D solution right now for a system that wants to run entirely open is a software rasterizer like llvmpipe, and even though it supports ppc64le its performance has not been great historically on our systems — see my poor struggling 4-core Blackbird running Xonotic at 1080p on the right. Fortunately, a modest but noticeable improvement is landing which should help. Apparently there's a hard cap of 16 threads, meaning all but the smallest 4-core Blackbird and T2 Lite machines were going underutilized, so now the cap is raised to 32.
-
Refactoring Russian Doll Code
Jane inherited a mess of code, and had to get it working as quickly as possible. She tidied up it as best as she could in the time, but now that the company depended on it, it needed some attention. We referred to it as her “Russian Doll code” because it had many nested functions, each passing the same giant nested lists back and forth. I could see that it frustrated her every time she had to touch it as she knew there was a better way to structure the code.
We booked in some 1:1 support sessions and sat down together with the aim of making the code easier to work with.
-
SciPy distribution for the odds ratio of independent beta variables
In biostatistics, a common effect measure when considering dichotomous exposures and outcomes is the odds ratio. With two proportions $π_0$ and $π_1$, the odds ratio is $ψ = \frac{π_1 / (1 - π_1)}{π_0 / (1 - π_0)}$, as compared to the risk ratio, $ρ = \frac{π_1}{π_0}$. Compared to the risk ratio, the odds ratio has the advantage that it is symmetric with respect to the exposure and outcome, and so can be computed from a case-control study where the population incidence of the outcome is not measured.
-
Directly computing HDIs from PDFs in SciPy
In Bayesian inference, it is often desired to calculate credible intervals for model parameters. The 2 common choices are the highest posterior density interval (HPD/HDI), and the equal-tailed interval. In many cases, the posterior density must be estimated by simulation, but in some cases the posterior density has a known closed-form expression, which enables these intervals to be directly computed.
-
R Shiny vs Shiny for Python: What are the Key Differences
If you haven’t been living under a rock for the past couple of weeks, you’ve likely noticed some groundbreaking news in the Shiny department. Yes, it’s finally available for Python! But how is the current Shiny for Python version? How does R Shiny compare vs Shiny for Python (PyShiny)? We have the answers, so continue reading.