Programming Leftovers
-
Exact integral of a polynomial on a simplex
The paper Simple formula for integration of polynomials on a simplex by Jean B. Lasserre provides a method to calculate the exact value of the integral of a multivariate polynomial on a simplex (i.e. a tetrahedron in dimension three). I implemented it in Julia, Python, and R.
Integration on simplices is important, because any convex polyhedron can be decomposed into simplices, thanks to the Delaunay tessellation. Therefore one can integrate over convex polyhedra once one can integrate over simplices (I wrote an example of doing so with R).
-
[Old] Re-creating a Byte Magazine Cover as a Photograph
Byte magazine was the leading personal computer magazine in the 1970s and 80s. Every month, its cover was adorned with a beautiful, surrealistic painting by Robert Tinney, showing a mash-up between computers and unrelated objects. The July 1977 issue featured an article about controlling a model railroad with a computer, and so Mr. Tinney painted a cover integrating a train with a computer board. According to Mr. Tinney, this “Computer Engineering” image is one of his most popular creations.
I wanted to create a piece of art that appeared to be a photograph of a real-life scene that Mr. Tinney might have painted. My first step was to obtain the components pictured in Tinney’s painting. Some of them are no longer manufactured – like the resistor and the big blue potentiometer with the black thumbwheel – or expensive to buy new, like the red transistor socket. I got what I could from eBay and compromised with a white thumbwheel on the potentiometer. I mocked up the component layout on a perfboard, designed the “circuit” (there isn’t actually a complete electrical circuit here) in DipTrace and sent it off to China to be manufactured.
(Projects like this are the main reason I use DipTrace or KiCad instead of Eagle Lite. The PCB I made is 5.5″ × 6″. The free version of Eagle would not have allowed me to make a board that big.)
-
Solving Rock-Paper-Scissors in Type-level Haskell
Let’s solve part 1 of today’s Advent of Code challenge “Rock Paper Scissors” in type-level Haskell.
Instead of using term-level programming as we usually do, we make Haskell’s type system do the work of calculating the solution. So the solution is be known right after we compile the program, and we do not even need to run the compiled program.
-
Gaussian Process Regression for FEA Designed Experiments – Building the Basics in R
Why would GPR be a good choice for modeling data produced by FEA? Well FEA is a deterministic modeling process – the prediction for any set of inputs (boundary conditions) is unique and repeatable. There is no noise or experimental error. This means a transfer function that passes through every point in the training data would be preferred. With a traditional regression model, the flexibility needed hit every data point would require many high order terms, sabotaging the model’s predictive ability on new data. But GPR has the amazing ability to swerve gently and fluidly between data points, meeting each one perfectly on its way to the next. This allows GPR to make perfect predictions on the training data while providing sound predictions in the areas in between the training points.
-
[Old] It’s Time For ‘Maximum Viable Product’ | by Clive Thompson | Debugger
“Feature creep” messes up a lot of good software.
We’ve all seen it happen to our favorite apps. We get an early version, we thrill to it; it does exactly what we want. We’re in love.
-
The broken bridge between biologists and statisticians | The coefficient of determination: is it the R-squared or r-squared?
We often use the coefficient of determination as a swift ‘measure’ of goodness of fit for our regression models. Unfortunately, there is no unique symbol for such a coefficient and both \(R^2\) and \(r^2\) are used in literature, almost interchangeably. Such an interchangeability is also endorsed by the Wikipedia (see at: https://en.wikipedia.org/wiki/Coefficient_of_determination ), where both symbols are reported as the abbreviations for this statistical index.
As an editor of several International Journals, I should not agree with such an approach; indeed, the two symbols \(R^2\) and \(r^2\) mean two different things, and they are not necessarily interchangeable, because, depending on the setting, either of the two may be wrong or ambiguous. Let’s pay a little attention to such an issue.
-
Version 0.13.0 of NIMBLE released - NIMBLE
We’ve released the newest version of NIMBLE on CRAN and on our website. NIMBLE is a system for building and sharing analysis methods for statistical models, especially for hierarchical models and computationally-intensive methods (such as MCMC and SMC).
-
Matthews Correlation Coefficient in R - finnstats
Matthews Correlation Coefficient in R, We can evaluate a classification model’s effectiveness using a metric called the Matthews correlation coefficient (MCC).
-
rOpenSci | postdoc 1.0: minimal and uncluttered HTML package manuals
This post is part of a series of technotes about r-universe, a new umbrella project by rOpenSci under which we experiment with various ideas for improving publication and discovery of research software in R. As the project evolves, we will post updates to document features and technical details. For more information, visit the r-universe project page.
-
Using Axios timeout to make your application more efficient
Axios is one of the most popular JavaScript libraries to do HTTP requests. It is an HTTP client available for both the browser and Node.js. Setting Axios timeout properly makes your application perform efficiently even when the called API/URL is not responding in a timely manner. In this post, you will learn about Axios, its configs, and how to set Axios timeout properly to not hamper your application’s performance. Let’s get going.
[...]
In today’s world of highly interconnected services and API economy, more often than not your application will call either external HTTP APIs or internal ones. Depending on how your company’s applications and the communication between them is architected, you are most likely calling some internal HTTP APIs. In addition to that, your applications might also be calling external APIs to accomplish all sorts of tasks from some AI-related calculation to creating shipments for a customer order.
Imagine this, your shipment application is calling the Auspost/DHL API to create a shipment and get an Airway Bill (AWB) number to send to the customer. Due to the last quarter of the year, the high traffic season of Black Friday and Christmas sales their API is responding extremely slowly. Usually, the create AWB HTTP API would respond in under 200 milliseconds (ms) but due to the load and ongoing issue at the time of calling it was responding in around 3 seconds.
This means that your warehouse (fulfillment center) staff are waiting for no direct benefit. In addition, as the API responses are flaky it is causing other issues too. This is where timeout on HTTP requests comes in handy, which is what is going to be discussed next.
-
Paolo Melchiorre - 2022 Malcolm Tredinnick MemorialPrize
It is difficult to write what a great honor it is for me that the Django Software Foundation has awarded me the 2022 Malcolm Tredinnick Memorial Prize, when it was announced to me via email by Anna Makarudze I was not sure how this was possible.
The two years leading up to this one were very difficult for me, but this last one I’ve been trying to make up for lost time and get back to participating in the life of the Django community in person. I have to admit that it was a reward just that I was able to meet so many amazing members of our community again, each of whom deserves this award.
-
A beginner’s guide to parse and create XML with Node.js
Writing and parsing XML files with Node.js might not be one of the first things that strike your mind. On the contrary, the Fast XML parser has millions of downloads per week on NPM. In this post, you will learn how to validate and parse XML with Node.js. You will also learn to generate an XML file from JavaScript objects. Let's get started!
-
Adventures in Advent of Code
The nature of last night’s problem was that, when I had a bunch of inputs, I could expect that there was only a single common element between all of them. After getting lucky and solving the problem correctly, I started golfing my code to make it terser. That’s when I started noticing something odd.
-
Better Coding Through Sketching
Back in the late 1970s and early 1980s, engineering students would take a few semesters of drafting and there would usually be a week or two of “computer-aided drafting.” In those days, that meant punching cards that said RECTANGLE 20,30 or something like that and getting the results on a plotter. Then we moved on to graphical CAD packages, but lately, some have gone back to describing rather than drawing complex designs. Cornell University researchers are trying to provide the same options for coding. They’ve built a Juypter notebook extension called Notate that allows you to sketch and handwrite parts of programs that interact with traditional computer code. You can see a video about the work below.
-
Day 4: Give the gift of time - Raku Advent Calendar
Lately, Santa was getting lots of letters that went a bit like this
-
Rewriting my blog again
Since this is a fully standalone client side webapp thing I can just host those four files and then write a Python Flask application that implements the same REST api that the nodejs backend provided.
This is exactly what I did, the whole backend is now a small Flask application that implements the Ghost API in ~500 lines of Python. It's called Spook (since this is dutch for ghost).