After a couple of weeks of hiatus (sometimes, actual work needs to get done), we are back to our pointless but fun weekend project: drawing mountains in a style similar to topographic maps , using shadows to hint at the relief. We are pretty certain that this must be a solved problem. We aren’t particularly interested in the result: this is more of an excuse to understand lights, and do a bit of…
Now that we have are setup to draw SVG on a page with Bolero , we can go back to our main quest: drawing mountains in a style similar to topographic maps , using shading to hint at the relief. In this post, I will go over how I approached computing the effect of light on a terrain. This post will be heavy on geometry, so let’s start with a teaser, showing the result first: Representing the terrain…
With a return to dungeon master duties, making maps has made a come back in my weekend activities, and I started revisiting an old side-project of mine, drawing mountains in a style similar to topographic maps . The aspect I am mostly interested in is not the contour lines, but rather the usage of shadows to visualize the relief. My goal here is as follows: given a grid of altitudes describing a…
This post is a continuation of my exploration of the RANSAC algorithm . In my previous post , I began investigating if I could auto-tune some of the input parameters. The first attempt was not a success, but gave me an idea, which will be today’s post. As a quick recap, RANSAC is a method to estimate a model in the presence of noisy data (so-called outliers). The method requires 2 input…
In my previous posts , I looked into the RANSAC algorithm . One thing I wondered about is, could the algorithm usage be made simpler by automatically tuning some of its input parameters? That is, rather than requiring the user to enter parameters, can we derive reasonable values for these parameters from the data? In this post, I will go over my first attempt. This was not a success, in that it…
In our previous installment , we set up the stage for our exploration of the RANSAC algorithm , illustrating how traditional linear regression could perform quite badly on a dataset with many suspect observations. In a nutshell, the estimation penalizes large prediction errors more heavily, and as a result, it can over compensate for a few very large errors (so called “outliers”), with a poor…
Recently, as part of a project I am working on, I had to estimate a model to make some predictions. And, as is usually the case, the data available was not very good, with a lot of suspect data points, so called “outliers”. Estimating the parameters of a model becomes tricky then, because a few data points that are very wrong can have an outsized impact on the parameters, and tilt the results of…
From time to time, a small and usually unimportant question gets stuck in my head, and won’t stop nagging me until I spend the time to figure out the answer. This post is about one of these. Last December, I mentioned in a post that “bigger teams require more coordination”, which would lead to diminishing returns to scale. As a team grows, it requires managers to coordinate activities. Grow the…
This post is part of the F# Advent 2025 series, which already has bangers! Check out the whole series, and a big shout out to Sergey Tihon for organizing this once again! It is that merry time of the year again! The holidays are approaching, and in houses everywhere, people are happily sipping eggnogg and hanging decorations. But in one house, the mood is not festive. Every year on December 1st,…
I came across this post on the fediverse the other day, pointing to an interesting article explaining the CVM algorithm . I found the algorithm very intriguing, and thought I would go over it in this post, and try to understand how it works by implementing it myself. The CVM algorithm, named after its creators, is a procedure to count the number of distinct elements in a collection. In most…
I was thinking recently about ways to combine prediction models, which lead me to the Softmax function. This wasn’t my first encounter with it (it appears regularly in machine learning, neural networks in particular), but I never took the time to properly understand how it works. So… let’s take a look! What is the Softmax function The Softmax function normalizes a set of N arbitrary real numbers,…
In my previous post , I took a look at handling the selected item in an Avalonia ListBox with FuncUI , so the ListBox properly reflects what item is currently selected, based on the current State . In this post, I will go into another aspect of the ListBox that gave me some trouble, handling dynamic updates to the list of items. Once again, this post is nothing particularly fancy, and is mainly…
After a brief summer hiatus, I am back! I wish this pause was due to exciting vacation plans, but unfortunately, the main reason was that I had a gas leak in my apartment, which ended up disrupting my routine quite a bit. Anyways, I am looking forward to enjoying simple pleasures of life like warm showers or home cooking again hopefully soon. Today’s post is not anything fancy. I have been working…
On February 25, 2023, I made the initial commit to Quipu. I needed a Nelder-Mead solver in .NET, and couldn’t find one, so I started writing my own. Today, I am happy to announce version 1.0.0 of Quipu ! What does it do? Quipu takes in a function, and searches for the arguments that minimize (or maximize) the value of that function. This is a problem that arises in many areas (curve fitting,…
I spent some time revisiting my solver library Quipu recently, looking in particular at improving the user experience when the algorithm encounters abnormal situations, that is, when the objective function could throw an exception. This in turn got me wondering about the performance cost of using try ... catch blocks, when the code does not throw any exception. Based on a quick internet search,…
For many reasons, I am not a fan of the current hype around Large Language Models (LLMs). However, a few months ago, I was asked to work on a project to evaluate using LLMs for a practical use case. I figured this would be an interesting opportunity to see by myself what worked and what didn’t, and perhaps even change my mind on the overall usefulness of LLMs. In this post, I will go over some of…
In my previous post , I went over fitting the parameters of a Log-Normal distribution to a sample of observations, using Maximum Likelihood Estimation (MLE) and Quipu , my Nelder-Mead solver. MLE was overkill for the example I used, but today I want to illustrate some more interesting things you could do with MLE, building up from the same base setup. Let’s do a quick recap first. I will be using…
Back in 2022, I wrote a post around using Maximum Likelihood Estimation with DiffSharp to analyze the reliability of a production system. Around the same time, I also started developing - and blogging about - Quipu, my F# implementation of the Nelder-Mead algorithm . The two topics are related. Using gradient descent with DiffSharp worked fine, but wasn’t ideal. For my purposes, it was too slow,…
In our last installment , I hit a roadblock. I attempted to implement Delaunay triangulations using the Bowyer-Watson algorithm, followed this pseudo-code from Wikipedia , and ended up with a mostly working F# implementation. Given a list of points, the code produces a triangulation, but occasionally the outer boundary of the triangulation is not convex, displaying bends towards the inside,…
During the recent weeks, I have been making slow but steady progress implementing Delaunay triangulation with the Bowyer-Watson algorithm . However, as I mentioned in the conclusion of my previous post, I spotted a bug, which I hoped would be an easy fix, but so far no such luck: it has me stumped. In this post, I will go over how I approached figuring out the problem, which is interesting in its…
In my last two posts, I did a bit of prep work leading to an implementation of the Bowyer-Watson algorithm . Now that we have the geometry building blocks we need, we can attack the core of the algorithm, and perform a Delaunay triangulation on a list of points. Rather than attempt to explain what a Delaunay triangulation is, I will leave that out, and simply illustrate on an example. Starting…
In my last installment, I started revisiting some old code of mine around Delaunay triangulation , the dual of a Voronoi diagram. My goal is to implement the Bowyer–Watson algorithm , and perhaps use it for procedural map generation at some point. I will follow the pseudo-code outlined on the Wikipedia page, and work my way through it. Last time I took care of the initialization step, computing an…
A while ago, I got interested in Delaunay triangulation , because it seemed to be a good building block for procedural map generation, city maps in particular. I started implementing the Bowyer–Watson algorithm , but ended up putting this side-project on ice, because, well, life got busy. I had something messy somewhat working back then, and figured it would be fun to revisit that code and try to…
Another Avalonia FuncUI post this week! One problem I struggled with initially with Avalonia FuncUI is how to handle async calls. I had some familiarity with the Elmish Cmd.OfAsync module, and wanted to use that if possible ( Maxime Mangel has a great post on Cmd and how to use them, if you are curious). Anyways, using Cmd.OfAsync and its cousin Cmd.OfTask in Avalonia FuncUI is what we will cover…
I have been using Avalonia FuncUI quite a bit lately, to develop Windows desktop clients for 2 applications. The UI for these applications is not particularly fancy: select items using listboxes, edit the selected item, and save it, that kind of thing. As these applications grew, the screens grew in complexity, and I realized that I was struggling a bit when I wanted to re-arrange their layout.…
In addition to re-designing my Nelder-Mead solver to improve usability, I have also recently dedicated some time looking into performance improvements. This is usually not my primary concern: I tend to focus first on readability and correctness first, and address performance issues later. However, in the case of a solver, performance matters. In my specific case, the solver works as a loop,…
In my previous post , I went over one of the changes I made to my library, Quipu , to make it more C# friendly. In this installment, I will go over another design change, turning the initial F# version, which used a classic pipeline, into a Fluent Interface. For reference, here is how the original F# pipeline looks like: let f ( x , y ) = pown ( x - 1 . 0 ) 2 + pown ( y - 2 . 0 ) 2 + 42 . 0 let…
During December, I have been aggressively redesigning my library, Quipu . I initially wrote Quipu because I needed a Nelder-Mead solver in .NET, and could not find one ready to use. And, because I intended to use it from F#, I wrote Quipu in a style that wasn’t particularly C# friendly. As I was going through the code base with my chainsaw, I thought it would be an interesting exercise to try and…
Since my earlier post looking into SIMD vectors in .NET , I attempted a few more experiments, trying to understand better where they might be a good fit, and where they would not. The short version: at that point, my sense is that SIMD vectors can be very handy for some specific scenarios, but would require quite a bit of work to be usable in the way I was hoping to use them. This statement is by…
Even though a lot of my work involves writing computation-heavy code, I have not been paying close attention to the System.Numerics namespace, mainly because I am lazy and working with plain old arrays of floats has been good enough for my purposes. This post is intended as a first dive into the question “should I care about .NET SIMD-accelerated types ”. More specifically, I am interested in…
The main reason I created Quipu is that I needed a Nelder-Mead solver for a real-world project. And, as I put Quipu through its paces on real-world data, I ran into some issues, revolving around “Not a Number” floating point values, aka NaN . tl;dr: the latest release of Quipu, version 0.2.2 , available on nuget , should handle NaN values decently well, and has some minor performance improvements,…
An old math problem I had not seen since my university days resurfaced the other day, the Maximum Flow problem . It came up in the context of analyzing some industrial process. For illustration purposes, let’s say we are producing sausages, following these steps: we grind some meat, add some seasoning, then stuff and tie the sausage casings, and split them into delicious sausage links. We could…
In my previous post, I went over the recent changes I made to my F# Nelder-Mead solver, Quipu . In this post, I want to explore how I could go about handling constraints in Quipu. First, what do I mean by constraints? In its basic form, the solver takes a function, and attempts to find the set of inputs that minimizes that function. Lifting the example from the previous post, you may want to know…
Back in April ‘23, I needed a simple solver for function minimization, and published a basic F# Nelder-Mead solver implementation on NuGet . I won’t go over the algorithm itself, if you are curious I wrote a post breaking down how the Nelder-Mead algorithm works a while back. In a nutshell, the algorithm takes a function, and finds the set of inputs that produces the smallest output for that…
In September, I had the great pleasure of attending the Data Science in F# conference in Berlin. I gave a talk and a workshop on Linear Programming , and figured I would make the corresponding material available, in case anybody is interested: Presentation: An Ode to Linear Programming Workshop: 4 levels of Linear Programming Linear Programming is perhaps an unusual topic for a data science…
This is a follow-up to my recent post trying to implement the classic Conway Game of Life in an MVU style with Avalonia.FuncUI . While I managed to get a version going pretty easily, the performance was not great. The visualization ran OK until around 100 x 100 cells, but started to degrade severely beyond that. After a bit of work, I am pleased to present an updated version, which runs through a…
A couple of days ago, I came across a toot from Khalid Abuhakmeh , showcasing a C# + MVVM implementation of the Game of Life on Avalonia . I have been experimenting with Avalonia funcUI recently, and thought a conversion would be both a fun week-end exercise, and an interesting way to take a look at performance. Long story short, I took a look at his repository as a starting point, and proceeded…
In the recent weeks, I came across a use case which sounded like a good fit for a desktop application, which got me curious about the state of affairs for .NET desktop clients these days. And, as I was looking into this, I quickly came across Avalonia , and specifically Avalonia.FuncUI . Cross platform XAML apps, using F# and the Elmish loop? My curiosity was piqued, and I figured it was worth…
Some time back, I wrote a small post digging into the mechanics behind the Nelder Mead solver . As it turns out, I had a use for it recently, and after copy-pasting my own code a few times, I figured it would make my life easier to turn that into a NuGet package, Quipu . So what does it do, and why might you care? A code example might be the quickest explanation here. Suppose that, for whatever…
This post is intended primarily as a note to myself, keeping track as my findings as I dig into automatic differentiation with DiffSharp . Warning: as a result, I won’t make a particular effort at pedagogy – hopefully you’ll still find something of interest in here! The main question I am interested in here is, how can I use DiffSharp to find the minimum of a function? I will take a look first at…
It is that time of the year again! The holidays are approaching, and the F# Advent calendar is in full swing. My contribution this year might not be for the broadest audience, sorry about that :) But if you are into F#, probability theory, and numeric optimization, this post is for you - hope you enjoy it! And big shout out to Sergey Tihon for making this happen once again. You can find the full…
This post is a continuation of my exploration of DiffSharp , an F# Automatic Differentiation library . In the previous post , I covered some introductory elements of Maximum Likelihood Estimation , through a toy problem, estimating the likelihood that a sequence of heads and tails had been generated by a fair coin. In this post, I will begin diving into the real-world problem that motivated my…
This post is intended as an exploration of DiffSharp , an Automatic Differentiation, or autodiff F# library. In a nutshell, autodiff allows you to take a function expressed in code - in our case, in F# - and convert it in an F# function that can be differentiated with respect to some parameters. For a certain niche population, people who care about computing gradients, this is very powerful.…
The Nelder-Mead algorithm is a classic numerical method for function minimization. The goal of function minimization is to find parameter values that minimize the value of some function. That description might sound abstract, but it deals with a very practical and common problem. For the Excel fans out there, the Goal Seek function is a concrete example of what function minimization is about. You…
For the longest time, my go-to charting library for data exploration in F# was XPlot . It did what I wanted, mostly: create “standard” charts using Plotly to visualize data and explore possible interesting patterns. However, from time to time, I would hit limitations, preventing me from using some of the more advanced features available in Plotly. Fortunately, there is a new game in town with…
Once again, I started a weekend project on a minor problem that ended up being more involved than expected. This time, the topic is random tables. Random tables are used often in role playing games, to create random items or ideas on the fly, based on a dice roll. The process of rolling physical dice is fun, but can be slow, so I started coding some of these random tables to help me keep the flow…
This post is a follow up to that one . As mentioned earlier, my overarching goal is to build a Discord bot to help play “atmosphere” soundtracks during D&D games. Last time, we went over creating a simple Discord bot in F# to support basic text commands. This time, we’ll add sound. How it works overall Our application builds on what we did last time. We will use DSharpPlus to create a console…
I have been using Discord a lot lately, mainly because I needed a space to meet for role-playing games remotely during the Black Plague. One nice perk of Discord is its support for bots. In particular, I used a bot called Groovy, which allowed streaming music from various sources like YouTube during games, and was great to set the tone for epic moments in a campaign. Unfortunately, Groovy wasn’t…
I have been obsessing over the problem of graphs layouts lately. To provide a bit of context, the starting point for that obsession was role-playing games. When running an adventure, you often need to quickly find various pieces of information, and how they are connected, for instance “Who is the leader of the Lampblacks”, or “What are notable locations in the Six Towers district”. This type of…
This post is part of the F# Advent Calendar 2019 . Check out other posts in this series, under the #fsadvent hashtag, and… happy holidays everybody :) It is that time of the year again for Santa, Inc. - a time of celebration for most, but for Mister Claus, a time of intense and stressful activity. Every year, keeping up with all these letters coming from kids everywhere, and assigning them to the…