Monthly Archives: May 2025

Computing Matrix Pseudo-Inverse Using Jacobi SVD with C#

In normal arithmetic, the inverse of 4 is 0.25 because 4 * 0.25 = 1. If you have an n-by-n square matrix A, the inverse of A is an n-by-n matrix Ainv where A * Ainv = I, and Ainv … Continue reading

Posted in Machine Learning | Leave a comment

“Understanding AI Large Language Model Transformers: an Analogy for Mere Mortals” on the Pure AI Web Site

I contributed technical content and opinions to an article titled “Understanding AI Large Language Model Transformers: an Analogy for Mere Mortals” on the May 2025 edition of the Pure AI web site. See https://pureai.com/articles/2025/05/01/understanding-ai-large-language-model-transformers-an-analogy-for-mere-mortals.aspx. The key technical component of large … Continue reading

Posted in Machine Learning | 1 Comment

Adding a Transformer Module to a PyTorch Regression Network – Classic NLP Positional Encoding

I’ve been looking at adding a Transformer module to a PyTorch regression network. Because the key functionality of a Transformer is the attention mechanism, I’ve also been looking at adding a custom Attention module instead of a Transformer. There are … Continue reading

Posted in PyTorch, Transformers | 1 Comment

Computing the Condition Number of a Square Matrix Using Eigenvalues and Power Iteration With C#

In mathematics, a condition number is a measure of how sensitive an object (array, matrix, etc.) is to some operation (dot product, matrix inverse, etc.) There are many different kinds of condition numbers. The condition number I come across most … Continue reading

Posted in Machine Learning | Leave a comment

Linear Support Vector Regression from Scratch Using C# with Particle Swarm Training

A few days ago, I was looking at linear support vector regression (linear SVR). Linear SVR is unusual in the sense that a model cannot be trained using standard techniques such as stochastic gradient descent or L-BFGS, because the loss/error … Continue reading

Posted in Machine Learning | Leave a comment

Analyzing the Horse Race Dice Game Using a Simulation

I played an interesting horse race dice game for the first time recently. The mathematics of the game intrigued me and so one evening while on a dreadfully long flight from Seattle to Boston, I wrote a short simulation (using … Continue reading

Posted in Miscellaneous | Leave a comment

“Linear Regression with Two-Way Interactions Using C#” in Visual Studio Magazine

I wrote an article titled “Linear Regression with Two-Way Interactions Using C#” in the May 2025 edition of Microsoft Visual Studio Magazine. See https://visualstudiomagazine.com/articles/2025/05/02/linear-regression-with-two-way-interactions-using-c.aspx. The most basic machine learning regression (predict a single numeric value) technique is called linear regression, … Continue reading

Posted in Machine Learning | Leave a comment

Computing the Condition Number of a Square Matrix Using Python and NumPy

In mathematics, a condition number is a measure of how sensitive an object (array, matrix, etc.) is to some operation (dot product, matrix inverse, etc.) There are many different kinds of condition numbers. The condition number I encounter most often … Continue reading

Posted in Machine Learning | Leave a comment

Computing the Least-Dominant Eigenvector and Eigenvalue of a Matrix Using Power Iteration and Rayleigh Quotient with C#

If you have an n-by-n square matrix, the matrix has n eigenvectors (each with n elements) and n eigenvalues. The eigenvalue with the largest absolute value is called the dominant eigenvalue, and the associated eigenvector is called the dominant eigenvector. … Continue reading

Posted in Machine Learning | Leave a comment

Matrix Inverse Using Cayley-Hamilton With JavaScript

The Wikipedia article on matrix inverse lists 14 different algorithms, and each algorithm has multiple variations, and each variation has dozens of implementation alternatives. The fact that there are so many different techniques is a direct indication of how tricky … Continue reading

Posted in JavaScript, Machine Learning | Leave a comment