Monday, April 6, 2026

Простили и помнили ...

Эти забыли.
А эти помнили
Да так помнили
Что праздник сделали
И по праздникам эти поняли,
Крутые наверное они были
Что без раздумья бы они повторили
И показали бы тем кто забыли.
Так из себя они возродили
Тех кого они не простили.
Глупые люди, не правда ли?
А те кто забыли
На всё забили
Да так вот забили
Что сами не поняли
Как из себя они возродили
Подобным тем кого забыли.
Глупые люди, не правда ли?
И по итогам этой были
И те кто помнили,
И те кто забыли
Наверное так ничего и не поняли.
Глупые люди, не правда ли?

Sunday, March 15, 2026

Aphorism 6

You don't regret
When you don't bet.
So, please ignore
Agent provocateur!

Agent provocateur is a strategy, used by famous scientists, for example:

If black holes do exist, Kip will get one year of Penthouse ... I paid the specified penalty, which was a one year subscription to Penthouse, to the outrage of Kip's liberated wife.

Stephen Hawking, A Brief History of Time

As well as famous artists/comedians, for example:

Sacha Baron Cohen realized that when people believe they are speaking to an idiot, they lower their defenses, cease trying to appear clever, and reveal their true selves, including their prejudices and biases.

(also here)

When cleverly staged, it can also reveal what people think about you ... just be sure to choose a topic you know extremely well ;)

Monday, January 5, 2026

Aphorism 5

Don't be Gauss to Abel!

The impact senior professionals may have on juniors can be tremendous. It's a great opportunity to share, help, promote and ... learn too.

The story of Gauss and Abel is covered by Wikipedia:

Abel sent a paper on the unsolvability of the quintic equation to Carl Friedrich Gauss, who proceeded to discard without a glance what he believed to be the worthless work of a crank.

As well as by the 2nd volume of the "Men of Mathematics" by E. T. Bell.

Saturday, January 3, 2026

Azi e ziua lui Tolkien

(3 Jan)
Azi e ziua lui Tolkien.
Chiar ar fi un mare chin
Să-l citești tot într-o zi.
Deci, noi filme vom privi!

Tuesday, December 9, 2025

Aphorism 4

Sh..t comes when nobody gives a sh..t.

This is a reflection on the "broken windows" idea from the "The Pragmatic Programmer". In case you don't have the book, see more here and here.

Thursday, December 4, 2025

A reflection on the COVID events ...

The kings of nature? Bloody hell ...
It sounds tempting, yet it's stupid.
Over the nature we "prevail",
With antivirus - outdated!

Monday, December 1, 2025

A startup story

Here is a story from the past startup times. It's a mixture of maths and technology, the kind of things I enjoy, as an applied mathematician by education.

Sometime in 2018, I was involved in an R&D project to detect periodic events. I will skip most of the technical parts, those curious can find the entire presentation here. The presentation ends with ...

... and this is the focus of this little post.

The preable of the story is that the VP of Engineering, a lot earlier before the start of this project, "swore" that they will buy champaign to the entire Data Science Team if we end up using Fourier Analysis for whatever purposes. Was it for fun or they were envisioning this project coming - I have no idea.

But, the team started "assessing the field". I started looking at a simplified unimodal model. After "doodling" for a couple of hours on a one A4 size page ...

... I came with some "expressions" allowing querying the database for periodic events using ... plain SQL! Amazon Redshift was returning results within 2 minutes. I still remember our CTO saying: "You nailed it!".

However, if you check the presentation, there is no Fourier Analysis there. It's just a simple application of the basic stats, limited to the unimodal model. It was enough though to trigger the further research and this simple model was used as a benchmark.

The team, eventually, started looking for multimodal techniques and Fourier Analyses (on terabytes of data!!!) ... and the team recalled the earlier "promise" from our VP of Engineering. We definitely had a party, I don't remember the champaign though ...

Sunday, November 9, 2025

Старая повесть ...

На столе лежала поэма "Возмездие", задуманная как эпопея ... в которой каждое новое поколение отвергает опыт отцов и, как ни печально, повторяет прежние ошибки ...

Ты залатаешь мои новые раны,
Я напишу тебе новую песню.
Время проходит, но не меняется
Сюжет этой очень старой повести.

Повесть в которой мы сражаемся
С теми же ветряными мельницами.
И как всегда, ничто не меняется
Разве что раны и новые песни.

Мне бы с тобой навсегда здесь остаться,
Просто писать тебе новые песни.
Но время проходит, сюжет не меняется
У этой чёртовой старой повести.

Saturday, November 8, 2025

Iluminați

Au trecut o sută de ani
Și o sută vor mai trece,
Timpul, însă, nu va șterge
Amintirile de oameni,
Care ne-au iluminat!

Wednesday, October 29, 2025

Aphorism 3

Don't mind the petty fight.
What matters is the final result!

On confirmation bias ...

The God regrets the day He took,
Uneducated to Facebook.
He also cries when people talk,
About news seen on TikTok.

Aphorism 2

Поздно пить Боржоми.
Но рано пить из крана!

Saturday, September 27, 2025

Aphorism 1

Ситуация между Богом и нами,
Такая же как и у нас с муравьями.

Friday, January 31, 2025

M-am dus ...

"M-ați lăsat și v-ați dus!"
La colț de sat striga pasărea.
Vântul vuia, nourii sus
Sumbră făceau imaginea.

"M-ați lăsat și m-am dus!"
Ca un cuțit tăia gandul.
Era altfel, să fi rămas?
Nu mai întorci timpul.

"V-am lăsat și m-am dus!"
Aducea un ecou vântul.
Această voce, de neîntors,
Îmi chinuia sufletul.

Sunday, October 20, 2024

Timpul trece …

Timpul trece și fără milă,
Timpul face să ne schimbăm.
Dragă frate, semeni cu tata.
Bine ar fi să ne revedem.

Ne cresc copiii, inevitabil.
Pleacă de-acasă, rar îi vedem.
Dragă fiică, semeni cu mama.
Bine ar fi să ne revedem.

Ne vine timpul, dar cresc nepoții.
Memorii distante ușor le uităm.
Dragă nepoate, eram ca tine.
Ne lasă timpul să ne revedem?

Saturday, June 15, 2024

Actori adevărați

Părinții, buneii, sunt ca eroii,
Tari, cuminți și cumpătați.
Nu prea vorbesc de taina morții,
Actori, mamă dragă, adevărați!







Și uite așa, de unii singuri,
Cu taina morții ne confruntăm.
Apoi cu timpul, fix ca părinții,
Noi ca actori ne comportăm.

Saturday, April 27, 2024

A few thoughts on faster sorting

In this article, I am presenting a sorting schema, hugely inspired by the Bucket and Proxmap sorting algorithms. I call it "schema", rather than "algorithm", simply because it introduces a (or another, depending on the sorting algorithm) "devide and conquer" element to the existing sorting algorithms, aiming (imho) to make them faster.

Also, let's recall that most of the sorting algorithms come with the time complexity $${\displaystyle O(N \log{N})} \tag{1}$$ With more details ...

1. The description of the schema

Let's suppose we have a list $L$ with $N$ (list size, thus a number) objects to sort. Now, let's imagine that we have $M$ (a number) buckets which are pre-sorted (buckets, not the content) according to the same criteria applied to sort the objects from the list $L$. Let's use strings as an example, if $$L=\{\text{BBBB}, \text{BBAA}, \text{AAAA},\text{...}\}$$ then we can "bucket" by the 1st letter of the string, giving us a total of 26 letters in the English alphabet (and yes let's ignore the case sensitivity and numbers and ... everything to keep things easy). We keep these buckets sorted as $$B_1=\{A\}, B_2=\{B\},...,B_{26}=\{Z\}$$ Then we partition/distribute the content of $L$ accross the buckets, sort the buckets individually and (finally) merge the content of the buckets to the final sorted list (simple traversal of the buckets, since they are already sorted). Something like this

What we have (in terms of time complexity) as a result

  • List $L$ traversal: ${\displaystyle O(N)}$
  • It's important that the distribution of objects to buckets is ${\displaystyle O(1)}$ per object, e.g. using hash maps
  • Sorting per bucket (from $(1)$) is ${\displaystyle O\left(\frac{N}{M} \cdot\log{\frac{N}{M}}\right)}$. Assumptions is that the content of the list $L$ is "uniformly" distributed (!!!) across the buckets.
  • Merging into the final list is ${\displaystyle O(M)}$. Again, buckets are pre-sorted.

2. The mathematical argument

Time complexity in the schema described above is $$ {\displaystyle O\left(N + M \cdot \frac{N}{M}\cdot \log{\left(\frac{N}{M}\right)}+M\right)} $$ which is $${\displaystyle O\left(N + N\cdot\log{\left(\frac{N}{M}\right)}+M\right)} \tag{2}$$ If we compare $(1)$ and $(2)$ $$\frac{N + N\cdot\log{\left(\frac{N}{M}\right)}+M}{N \cdot\log{N}}= 1-\frac{\log{M} - 1}{\log{N}}+\frac{M}{N\cdot\log{N}} \tag{3}$$ Assuming large enough $M < N$ we have $$\frac{N + N\cdot\log{\left(\frac{N}{M}\right)}+M}{N \cdot\log{N}}< 1-\frac{\log{M} - 2}{\log{N}}< 1 \tag{4}$$ In other words, for large $N$ and $M$ we should expect this schema to make most of the sorting algorithms "a little bit" faster. By how much? Let's see ...

3. Specific example

Let's consider lists of strings as an example. Here is the source code of a little PoC project which generates lists of randomly generated strings and sorts them using

  1. the Java's Collections::sort and
  2. an implementation of the schema above, which internally uses Collections::sort as well to sort the content of the buckets
and compares the results. No parallelisation is used, although sorting buckets in parallel could significantly improve the speed in the second (B) case, but no cheating!

Most of the aspects in the code are easy to tune, but we will consider only

  • lists of size $N=1000000$ and $N=3000000$ and
  • bucketing by the first 2 letters, giving the total number of buckets $M=26^2$

Plugging these numbers into the formula $(3)$ we should expect

$M=26^2$ and $N=1000000$ $M=26^2$ and $N=3000000$
0.60 0.63

An improvement of nearly $40$%!? No way ...

4. Actual results

One more test parameter I should mention (and which is not part of the formula $(3)$) is $X$ the length of each string added to the list $L$, this is to count for Java string comparison where string size plays a role. We will look for $X=10$, $X=50$ and $X=100$. Here are some results from running the PoC code on my fairly old computer with an Intel i5-3330 3.00GHz 4 Cores CPU on board, using Java 17

$X=10$, $M=26^2$ and $N=1000000$ $X=10$, $M=26^2$ and $N=3000000$
Reported result:
  Fast Sort avg: 422.33ms
  Std Sort avg: 677.96ms
    
Reported result:
  Fast Sort avg: 1484.24ms
  Std Sort avg: 2395.39ms
    
$\frac{422.33}{677.96}\approx 0.6229$ $\frac{1484.24}{2395.39}\approx 0.6196$

A few more results

$X=50$, $M=26^2$ and $N=3000000$ $X=100$, $M=26^2$ and $N=3000000$
Reported result:
  Fast Sort avg: 1545.82ms
  Std Sort avg: 2773.65ms
    
Reported result:
  Fast Sort avg: 1561.84ms
  Std Sort avg: 2883.08ms
    
$\frac{1545.82}{2773.65}\approx 0.5573$ $\frac{1561.84}{2883.08}\approx 0.5417$

5. Conclusions

Well, the test results are not too far off from the calculated results. So, the schema does improve the sorting ... However, I should mention the following:

  • It works well when the list $L$ is "uniformly distributed" across the buckets (already mentioned in section 1). Imagine that all the objects fall into one bucket, then we are back to ${\displaystyle O(N \log{N})}$ or slightly worse.
  • The test times don't include the time required to "build" the buckets. Buckets are meant to be "built" once and re-used.

And finally, the schema allows for

  • parallelisation, content of the buckets can be sorted in parallel and
  • imagine a data streaming scenario, if one bucket is updated, we don't have to re-sort the entire list $L$

Sunday, April 7, 2024

A property of the Prime Counting function

While addressing this question on MSE the following inequality was revealed, concerning the Prime Counting function ...

For $\forall x,y$ such that $60184\le x< y$ we have: $$\frac{x}{\pi(x)} < \frac{y}{\pi(y)} + 1$$

Friday, April 5, 2024

De fapt ...

"De la istoria cu pomul,
S-a mai cumințit oare omul?"
Intreabă odată Domnul,
Pe slugă-Sa, Satan.

Acela, surprins de întrebare,
Cu fața plină de mirare,
Răspunde într-o răsuflare:
"De fapt ..."