Carlo Nicolini
science tech publications software cv search

Blog

  • Apr 14, 2026

    Agentic Soft Logical Circuits: from ReAct Chains to Structured Variational Inference

    I have been spending a lot of time lately staring at agent logs.

  • Apr 13, 2026

    The continuous Sheffer stroke is all you need

    All elementary functions from a single operator

  • Apr 11, 2026

    From brain to disk: how I built a voice-activated second brain for $0

    We’ve all been there. You’re out for a walk or just about to fall asleep when a perfect idea hits. You grab your phone, record a quick voice note, and then… it just sits there. It becomes a digital fossil in your chat history that you’ll probably never listen to again.

  • Apr 9, 2026

    Interpretations for the Kullback-Leibler divergence, or relative entropy

    This page follows the structure of Six (and a half) intuitions for KL divergence by Callum McDougall (2022); equations are set for MathJax.

  • Apr 5, 2026

    From hard to soft operators: between machine learning and statistical physics

    An academic exploration of deep learning, statistical mechanics, and category theory

  • Apr 4, 2026

    Random rooted trees, continuation free energy, and the Diligent Learner

    Why these two theories should meet

  • Apr 3, 2026

    Short-prefix soft values: a null result

    Abstract

  • Apr 3, 2026

    Recursive decomposition with a continuation policy

    Abstract

  • Apr 3, 2026

    MellowMax, Doob's h-transform, and the intensive geometry of tool-use agents

    Abstract

  • Apr 2, 2026

    Soft values, symmetry breaking, and random rooted trees

    A missing local law

  • Apr 1, 2026

    Inference-Time Steering as a Discrete Schrödinger Bridge

    The limits of passive filtering

  • Apr 1, 2026

    Category theory and PLP: keeping the theory in order

    Why use category theory here?

  • Mar 31, 2026

    PLP is inference-time approximation of free energy

    Approximate sampling and inference in LLMs

  • Mar 27, 2026

    Test-time inference, language models and energy based models

    The link between autoregressive models, energy based models and probabilistic language programming

  • Mar 25, 2026

    Scaffolding is all you need

    Toward a reliability theory of AI compound systems

  • Mar 16, 2026

    Running Claude Code via OpenRouter in Docker

    AI coding agents like Claude Code are incredibly powerful, but running them directly on your host machine can feel risky. Containerizing them is the logical step, but it often leads to auth conflicts, 401 errors, or terminal freezes.

  • Mar 14, 2026

    Unleash Claude Code CLI with OpenRouter: Free AI Coding Power!

    Claude Code CLI with OpenRouter

  • Mar 1, 2026

    Probabilistic Language Programming, turning craft into solid science

    Assigning semantic meaning to probabilistic programs

  • Dec 26, 2025

    Intelligenza Artificial Neurosimbolica

    Verso l’integrazione fra AI simbolica e AI neurale

  • Oct 3, 2025

    Introducing skfolio new online convex optimization module

    Bridging online convex optimization into skfolio

  • Sep 26, 2025

    Running LM-Studio headlessly on Ubuntu 24.04 with CUDA

    Running LM-Studio Headlessly on Ubuntu 24.04 with CUDA and Systemd

  • Mar 30, 2025

    Configuration-model Surprise for community detection

    From vertex pairs to stubs

  • Jan 30, 2025

    Unlocking the Power of DeepSeek R1 via HuggingFace's TogetherAI

    In the evolving landscape of artificial intelligence, the ability to interact with intelligent APIs has become a fundamental requirement for developers and organizations alike. Today, we explore how to harness the capabilities of the DeepSeek R1 model from HuggingFace through the TogetherAI service, highlighting its practical applications and utility.

  • Jan 16, 2025

    Prompt Chaining with Foundational models

    In the rapidly evolving world of artificial intelligence and natural language processing, one of the most innovative concepts emerging is Prompt Chaining. This method optimizes the capabilities of Large Language Models (LLMs) by enabling a structured, step-by-step collaboration among multiple prompts. Let’s delve into what prompt chaining is all about, its use cases, and a practical implementation.

  • Jan 15, 2025

    Creating the How2 Function for Natural Language Bash Commands with LLM

    In today’s tech-driven world, the ability to translate natural language into executable commands is a powerful tool for developers and system administrators alike. Recently, I embarked on creating a function that bridges this gap using a Large Language Model (LLM) to interpret user queries in natural language and return the corresponding Bash terminal commands. Here’s how I constructed the how2 function that provides users with Bash commands based on their queries. The trick is to use the fantastic LLM-CLI command by Simon Wilson llm. Then one needs to wrap the calls to LLM into a specific bash function called how2.

  • Jun 30, 2024

    Multilabel classification with Parabel and efficient at-k metrics

    The annoying gap in extreme multilabel classification

  • Feb 2, 2024

    Installing XFormers on Mac M1/M2

    XFormers

    XFormers is a deep learning library to implement many complex attention operations. It focuses on providing the Memory Efficient Attention as well as many other operations. For example it also has BlockSparseAttention support or any other forms of attention where the attention bias matrix induces a complex attention pattern, like for example in the sliding window attention used in Mistral models

  • Mar 6, 2023

    How to start your Docker compose service at startup

    This is how you do:

  • Jan 14, 2023

    Calculate a file hash in Python

    This code helps you calculating the SHA256 hash of a file in Python. This could be helpful for the disambiguation of different files.

  • Jan 14, 2023

    Augmentation of documents for neural networks training

    Why augmentation of documents

  • Nov 23, 2022

    Slicing rolling expanding windows over multiple pandas objects

    This is a fast way to yield a subset of rows from multiple Pandas dataframes or Series, when one needs to work on a sliding window basis over a predefined minimum and maximum number of rows. This approach is among the fastest available and is based on the .iloc accessor of both series and dataframes.

  • Sep 15, 2022

    Dependencies For Having Detectron2 Running On Mac Os

    Python dependencies for having detectron2 running on Mac OS

  • Jul 8, 2022

    How to enable colab for longer runtimes by keeping it active

    This post is of help:

  • Jun 15, 2022

    How to download google sheet data to Pandas

    All you need is a Google Sheets file with one or more sheets and of course some data. The file needs to be set to the sharing option which allows everyone with the link to view the data.

  • May 3, 2022

    Better graphics with matplotlib and seaborn

    High–quality figures are not an aesthetic afterthought. In scientific communication they determine readability, reproducibility, and perceived rigor. Default matplotlib settings are optimized for quick inspection, not for publication. The configuration below standardizes typography, layout, and rendering so that figures are suitable for papers, slides, and vector export.

  • Dec 3, 2021

    Changepoint detection on huge grouped dataframes with ruptures and PySpark

    Here we describe a way to perform scalable changepoint detection on grouped time series data by using PySpark and the rupture library.

  • Dec 3, 2021

    Rolling operations in PySpark

    Have you ever wondered how to perform rolling averages in PySpark? This snippet helps you through the process

  • Oct 15, 2021

    Sampling 10 rows per groupb in PySpark

    You need to use a window partition by and let the random number do the shuffle for you.

  • Sep 28, 2021

    Docker on MacOS

    How to install Docker on MacOs

  • Jul 28, 2021

    How to make HDBScan an inductive clustering method

    There is a large difference between inductive and transductive clustering methods. While the first are more similar to supervised learning, in the sense that once trained on N examples they can generalize to M unseen new samples, transductive method instead need to see all data, but cannot generalize to new samples.

  • Jul 28, 2021

    How to convert networkx graphs to graph-tool

    How to convert networkx graphs to graph-tool

  • Jun 21, 2021

    Finding and deleting memory hungry temporary variables in jupyter notebooks

    This simple command displays the name of the variables in the current kernel in Jupyter notebooks, whichi are clogging our memory resources the most.

  • May 18, 2021

    Plotly And Jupyterlab

    If you have problems with empty plotly output in jupyterlab remember that you need these packages:

  • Oct 23, 2020

    The Woodbury matrix identity

    The Woodbury matrix identity is a useful identity in linear algebra. It says that you can invert the sum of a matrix plus a $k$-rank correction by doing a rank $k$-correction to the inverse of the original matrix. It is also called matrix inversion lemma or Sherman-Morrison-Woodbury formula.

  • Oct 9, 2020

    Versioning data files for machine learning projects with DVC

    DVC Tutorial

  • Oct 5, 2020

    Prefixspan algorithm for frequent subsequences visualization

    Sequential pattern mining and projections

  • Sep 4, 2020

    Code indentation in Python with Black

    A very nice code indentation tool for Python is called Black

  • May 18, 2020

    How to merge Dataframes in spark as in Pandas

    This is how you do it:

  • Apr 20, 2020

    Some scala functions as exercise

    Here are some very basic function with self-explanatory name, to be coded in Scala for a super beginner. Some of them are very inefficient, pay attention to use them, they are only for demonstration.

  • Apr 1, 2020

    Installing Jupyter with a Scala + Spark kernel

    Installazione SCALA + SPARK + Jupyter

  • Mar 27, 2020

    How to remove all logging information in scala spark

    Create a folder named “log4j” in the root folder of your project (the one where build.sbt stays) and then create a file named “log4j.properties” with the following content:

  • Nov 14, 2019

    Eigenvectors from eigenvalues a numpy implementation

    Simple ideas can make good numerical algorithms

  • Sep 3, 2019

    Sampling uniform spanning forests with Wilson algorithm in Python

    Stochastic ways to determine the laplacian spectrum

  • Jun 12, 2019

    The link between machine learning and statistical physics

    Reading the paper by Max Tegmark “Why does deep and cheap learning work so well” is illuminating.

  • May 3, 2019

    How to expand the loopback device size

    From this answer

  • Apr 18, 2019

    Quantum statistical mechanics of complex networks in networkqit

    With this post I am introducing to the public my very first complete Python package networkqit.

  • Mar 21, 2019

    Hidden Markov Models

    In these notes I want to introduce Hidden Markov Model, one of the simplest but rich enough models to handle real world applications for modeling sequential models.

  • Mar 18, 2019

    Short introduction to measure theory

    In these notes, we’ll take a look at the bare essentials of modern probability theory. We’ll describe the basic ideas, but we will skip Lebesgue integration, at the moment. To do this, we need to introduce some measure theory first, to see how things emerge naturally and beatifully.

  • Mar 13, 2019

    Low rank estimation of sparse observed ratios

    Reccomender systems are a class of algorithms to deal with missing information. Given that we have some available rate about the relations of a set of objects, and these informations are specified by real numbers, how can we estimate the relations between another subset of objects that we did not observe?

  • Jan 25, 2019

    Smooth approximation to the floor function

    I need to sample random numbers distributed according to the geometric distribution. Similarly to the Box-Muller transformation, which is a method to sample normally distributed random numbers based on a uniform random generator, I have found that any probability distribution admits one-liners, i.e. deterministic transformations of the uniform distribution that allow to sample random numbers for specific distributions.

  • Jan 17, 2019

    Visual inspection of python profiler output with gprof2dot

    Ever wondered how to make a beatiful and powerful call graph from your python profiler? I have found that there is no need to install heavyweight tools like KCachegrind or even worse, buying expensive IDEs. The solution is simple.

  • Jan 16, 2019

    Einstein summation in Numpy

    Einstein summation is a convention in tensor algebra where repeated indices are implicitly summed. For example, imagine we have a matrix (a tensor of rank 2) $A_{i,j}$. To compute the trace, i.e. the sum of diagonal elements one has to compute

  • Nov 27, 2018

    Showing brain parcellation in Python with nilearn and some hacking

    In this post I would like to introduce to the nilearn user, a modified set of functions based on the nilearn.surface module, that are of great help in making beautiful surface colored pictures of brain, like the one in this figure:

  • Nov 12, 2018

    Faceting images or generic plots with Seaborn and Python matplotlib

    I’ve found myself working with large pandas dataframe. Differently from the typical usage of pandas dataframes, in some cells I have numpy.array as content, or other types of data. Here we call these non-standard columns as x and y.

  • Sep 12, 2018

    Weighted graphs from adjacency matrix in graph-tool

    I was playing a bit with networks in Python. In my daily life I typically work with adjacency matrices, rather than other sparse formats for networks. Adjacency matrix is pretty good for visualization of communities, as well as to give an idea of the distribution of edge weights. It is exactly in the domain of weighted networks that I need to be able to fit stochastic block models to my observations. Doing this requires the super-cool library of Tiago Peixoto graph-tool.

  • Jul 10, 2018

    Install latest igraph 0.7.1 for Python3 on Ubuntu

    If you choose to use the igraph library with Python 2, it’s a cakewalk to get it running on a fresh install of Ubuntu 16.04:

  • Jul 10, 2018

    How to list all tensorflow devices

    This is how you do:

  • Jun 25, 2018

    Random matrix ensemble spectral density and the average resolvent

    This short blog note is covering some aspects related to interesting calculations that can be done in random matrix theory applied to the study of spectral properties of random graph models, like those shown in Figure:

  • Jun 24, 2018

    Some considerations about the spectral entropies framework

    I am illustrating some of the ideas that emerged before, during and after the conference. How to compute this quantity?

  • May 21, 2018

    Dataset of biologically derived graphs

    This website contains a number of interesting dataset of biologically derived graphs.

  • May 21, 2018

    Why probabilistic programming matters

    I recently stumbled across the idea of probabilistic programming, something I had never heard before. Indeed with the recent advances in artificial intelligence and machine learning, this field is seeing a very rapid development. The motivation why I found this research field particularly interesting is its cross-talk with the ideas I developed in one of my last works on inference within the spectral entropy framework.

  • May 11, 2018

    Inequalities, traces, densities, matrices

    Let us compute the following quantity:

  • May 11, 2018

    An identity for zero

    This identity could result useful

  • Mar 12, 2018

    Distance matrix of the air500 complex network

    The air500 network is the adjacency matrix of the largest 500 airports in the world.

  • Mar 1, 2018

    Lambda functions composition in Python 3

    Introduction

  • Sep 27, 2017

    A Graduate Course in Econometrics

    Introduction to matrix econometrics

  • Sep 22, 2017

    A Full Undergraduate Course in Econometrics

    This series of notes is from the Ben Lambert’s course on econometrics, a discipline mixing calculus, linear algebra and statistics in a way that I believe is very enjoyable for a physicist-minded person. The series of courses is available at the following Youtube link:

  • May 12, 2017

    The Enhanced weighted random graph model (EWRG)

    The ensemble of maximally random weighted graphs with the constant average number of edges and total weight.

  • May 10, 2017

    Plugging the weighted random graph into Surprise

    Surprise is based on the calculation of the number of simple graphs with \(n\) nodes and \(m\) edges exactly. This null model is called \(G_{nm}\) model and it is the microcanonical version of the Erdos-Renyi model also called \(G_{np}\). To be more precise, Surprise does not compare against a fixed null model, but the null model is dependent on the partition itself. In other words, the expected fraction of intracluster edges is given by \(p_\zeta/p\) and it is clearly dependent on the partition it self. For this reason Surprise is more similar to the Constant Potts Model than to a model where intracluster density is compared to a fixed constant.

  • Feb 12, 2017

    How to stop with CTRL C a running mex file in Matlab

    This is how you do:

  • Feb 12, 2017

    Eigenvalue spectra of modular matrix techniques and calculations

    RANDOM NOTES ABOUT RANDOM GRAPHS AND EIGENVALUES, NOT TO BE TAKEN SERIOUSLY

  • Jan 27, 2017

    How to grant specific directory access to users in linux

    Negative ACLs

    You can prevent a user from accessing certain parts of the filesystem by setting access control lists. For example, to ensure that the user abcd cannot access any file under /home:

  • Jan 20, 2017

    Assigning XRDP to different users

    /etc/rc.local write xrdp-sesrun 127.0.0.1 brainet neuron128 1280 1024 24

  • Jan 17, 2017

    How to create a large swap file in Ubuntu if system runs out of memory.

    Check this guide:

  • Jan 17, 2017

    TAB is not working with XFCE4 after installation from Ubuntu for use with remote desktop

    You have installed Ubuntu 14.04 or latest Ubuntu LTS 16.04 on your server and you want to make it available for remote desktop connections with the help of XRDP. You install xrdp and you connect to your server with some client, like remmina. Suddenly XFCE4 is showing up in its simplicity.

  • Jan 16, 2017

    Matlab and CUDA gpudevice freezes on Ubuntu 14.04 with GTX 1070

    In Ubuntu 14.04 with MATLAB R2016b it may happen that after an installation of CUDA8 and NVidia drivers 367, the calls to specific CUDA functions such as gpudevice or gpuArray are very slow the first time you call them. This is because MATLAB R2016b it’s not built against the latest CUDA drivers so fat binaries have to be built once. In this case, MATLAB is using a CUDA toolkit (7.5) which does not support the new Pascal architecture on my Geforce GTX 1070. This operation may take some minutes to end, as nearly 400 MB have to be compiled and saved in .nv/ComputeCache. In theory this cache is built once and every successive instance of MATLAB should not take too long for first calling CUDA functions. Anyway it is the case that this is not completely true.

  • Dec 24, 2016

    Computing Euler angles from 3x3 rotation matrix in Matlab

    Computing Euler angles from a rotation matrix is straightforward once you set a convention. Indeed is possible to compute an entire different set of angles that defines a rotation when you change axis. In this case I use the aeronautical notation, with pitch, yaw and roll as a plane taking off.

  • Oct 28, 2016

    Computing hypergeometric probability efficiently in C++

    Computing hypergeometric function is a slow and difficult process, often affected by overflow errors as evaluating binomial coefficient may return extremely large numbers. Fortunately, thanks to some hypergeometric identities, is possible to evaluate the hypergeometric probability quickly.

  • Oct 6, 2016

    How to start a SSH daemon on Windows without agonizing pain

    I recently needed to connect via ssh to my windows computer from a Linux server, but I couldn’t figure how to do it since ssh servers for windows are expensive and I don’t want to pay for a software that on Linux comes for free. Some of the typical ssh servers (daemon in linux terminology) are bitvise tunnelier, freesshd.

  • Oct 6, 2016

    How to upgrade R to the latest version on Ubuntu 14.04

    Follow this instruction:

  • Oct 6, 2016

    A code for the absolute orientation problem with Umeyama algorithm in Python

    A code for the absolute orientation problem solved with Umeyama algorithm. Explanations, briefly.

  • Sep 13, 2016

    Delaunay triangulation and beautiful visual effects in Latex

    Recently in the world of the Internet this very fancy coloured pattern appeared:

  • Aug 26, 2016

    Comparing spectral densities of random graph models.

    The ability of quantitatively comparing two graphs is of great importance in many scientific questions and of exceptional importance in studying brain networks. How the brain networks of healthy people differ from those of patients? What kind of alterations are present in the functional connectivity of diseased brain? To what extent two networks are structurally similar?

  • Aug 17, 2016

    Matlab R2016a crashes on Ubuntu 16.04 with NVidia 361 drivers

    For those of you who upgraded Ubuntu from 14.04 to 16.04 and have found that Matlab is crashing with errors in nvidia drivers, you have three options:

  • Aug 10, 2016

    Fix black screen after upgrade from Ubuntu 14.04 to Ubuntu 16.04

    I’ve just decided to upgrade my Ubuntu 14.04.4 to the latest Ubuntu distribution 16.04.1. To do this I’ve followed the instructions and after the installation rebooted my computer.

  • Aug 2, 2016

    Using-VNC-persistent-sessions

    In this guide I briefly explain how you can get remote persistent session on the Mattarello Linux servers from any local computer, Windows, Linux or OSX.

  • Aug 1, 2016

    Setting up VNC sessions in Linux

    Server side

  • Jul 16, 2016

    Launching-matlab-in-background-correctly-in-linux

    You want to launch Matlab for a very long script and then disconnect your remote terminal, and when back, not finding bad surprise.

  • Jun 27, 2016

    How to install latest R on servers under proxy

    It’s possible to keep your R version updated on Ubuntu 14.04 if you decide not to use the version provided by the package maintainer. In this small guide I explain how to do that especially if you are under a proxy server.

  • Jun 16, 2016

    Get the exact print size of a PDF in inches

    This is the command to do the stuff

  • Jun 16, 2016

    Forwarding-X11-maintaining-connection-with-xpra

    How to use XPRA for remote connection to the NeuralComputation Linux servers hosted in Mattarello

  • Oct 14, 2015

    Install Google Drive for Linux

    Gsync is the rsync for Google Drive. If you like me, have unlimited storage space on Google Drive, this guide that can be very useful to you. You can store your precious date on the google cloud with the warranty that they are not lost nor destroyed. Google treats data very seriously :smile: (pun intended).

  • Oct 14, 2015

    Detecting the consensus communities in graphs

    In these section we’ll address in depth an approach to making sense of the mesoscopic structure of a network by means of non-deterministic methods. We will take advantage of the methods of statistical physics and treat with ensembles of partitions to assess the statistical significance of community structure.

  • Oct 13, 2015

    How to install Octave on OSX Yosemite

    For those who have problems installing Octave on OSX Yosemite, this is a simple guide.

  • Oct 5, 2015

    How to reset unity in Ubuntu 14.04

    For those who struggle with frequent freezes of Unity, this is a short guide on how to reset Unity to default settings in Ubuntu 14.04.

  • Sep 25, 2015

    Matlab imagesc with text values

    Well. Finally got around to making a better imagesc function in Matlab and Octave. I’ve named it imagesctxt and it has the same arguments as imagesc.

  • Contact
  • surname.name@gmail.com
  • carlonicolini
  • RSS

Personal blog about artificial intelligence, coding, statistical physics, network theory and science in general