Thursday, February 27, 2025

Bayesian broadcast newsletter E01

Bayesian broadcast newsletter, E01

Gautam Bhanage

Published at www.bhanage.com

Feb 2025


About

These are a mishmash of interesting articles I have read over a period of time, approximately over a month. Articles are referenced in no particular order. Topics are all over the place ranging from science, engineering, philosophy, programming to anything that sounds remotely interesting. None of these serve as personal recommendations or endorsements. Purely for fun.


Quotes and quips

Quotes that stuck with me recently - 

  1. "I do not think that the radio waves I have discovered will have any practical application". Quote from Heinrich Hertz's discovery of radio waves in the 1880s. This is a reminder for us to never underestimate the power of new information. Discovery of radio waves eventually formed the basis of all forms of wireless communication, changing the world forever.

  2. "Remember that an airplane takes off against the wind and not with it" - Henry Ford. Interesting quote that reminds us some amount of friction is needed before something meaningful is achieved.


Interesting articles

1. Watt The Fox? -  An interesting read about how Firefox (a popular browsers) creates Audiocontext for webaudio and does not end up suspending AudioContext when done -> which results in the laptops sending out white noise (can be heard feebly when everything is silent) -> which results in powermetrics/powerstat showing that the system has an additional 1.5W ambient power usage -> which causes the battery to drain faster.

tags: Linux, power usage, embedded systems, browser interaction


2. Comments on NASA's 10 rules for programming - Contains an interesting bunch of rules and the author primarily discusses them in the context of C programming and how they would apply. While there is some good advice in the directives, it is not easy to follow all of the rules without resulting in some convoluted code. A good read nonetheless. 

tags: Programming, C, Linux


3. Management lessons from the challenger space shuttle disaster - This is the second reference to NASA, but we are not following a theme here. Rather, this is an insightful article on managing risky programs. Key take-aways - 1) Establish priorities and follow through e.g. safety before launch, 2) Avoid groupthink - i.e in a bid to reach consensus do not miss identifying critical issues noted by strong team members, and 3) Trust your team's recommendation - this is is for senior leadership to take recommendations seriously. One more thing not called out in the article, but I felt was important is avoiding normalization of deviance. E.g the safety of the o-rings in cold weather (which eventually caused the crash) was called out by the team, but ignored by senior management since they had done this in the past for previous programs. This should not have been ok when such a critical program was being launched.

tags: management, leadership, lessons, better leader, risk management, TPMs


4. Intolerable genius - An interesting read on how a scientist taking LSD came up with a way to make copies of DNA leading to him winning the nobel prize in chemistry. Coined as Polymerase chain reaction (PCR), this was a breakthrough in helping us detect genetic mutations like sickle cell disease in under 12 hours. Another interesting read is the impact on ancient DNA.

tags: science, biology, genetic, chemistry, nobel prize


5. Shallow vs deepcopy of objects in python - Like in some other languages, assignment statements (=) in Python do not copy objects, they create bindings between a target and an object. The difference between shallow and deep copying is only relevant for compound objects (objects that contain other objects, like lists or class instances): A shallow copy constructs a new compound object and then (to the extent possible) inserts references into it to the objects found in the original. A deep copy constructs a new compound object and then, recursively, inserts copies into it of the objects found in the original.

tags: programming, python, refresher, quick read.


Notable open source repositories

1. Awesome LLM apps - A repo that contains a collection of AI agents ranging from investment assistants to tutorials, to RAGs and everything in between. 


2. Miniaudio - miniaudio is written in C with no dependencies except the standard library and should compile clean on all major compilers without the need to install any additional development packages. All major desktop and mobile platforms are supported.


Research papers

1. "Network Control by Bayesian Broadcast", Ronald Rivest. This is the original paper from 1987 that got me interested in MAC layer optimizations that make networks cooperate and deliver information across. In a slotted aloha system, each of the transmitters estimate the probability of a collision, a hole or a successful transmission to adapt and optimize. My newsletter is a namesake from this paper. 

tags: networking, probability, math, research


Closing comments

For the future, I might try to make newsletters more focussed on a theme. It really depends on how I feel about it at that time. Until then, thanks for reading.


Tuesday, October 15, 2024

Math: Convolution for RSU vestings

 Probably pretty late, but I just realized that when computing compensation per year based on stock vests, you are essentially running a convolution of two lists. 

L1 = Vesting schedule

E.g. if the vesting schedule per year is 10% for Y1 and Y2 followed by 40% for Y3 and Y4, we could represent L1 = [0.1, 0.1, 0.4, 0.4]

L2 = RSUs allocated per year. Consider an example where you get 500 for Y1, 300, 400, 200 for the remaining years respectively.

Running the convolution across these lists:

Vesting schedule

Grants       [500 300 400 200]

Plan [0.4, 0.4, 0.1, 0.1]

$(Y1) = 500 * 0.1 = 50


Yr2

Vesting schedule

Grants       [500 300 400 200]

Plan [0.4, 0.4, 0.1, 0.1]

$(Y2) = 500*.1 + 300*.1 = 80


Yr3

Grants               [500 300 400 200]

Plan [0.4, 0.4, 0.1, 0.1]

$(Y3) = 500*.4 + 300*.1 + 400*.1 = 270

And so on.. 

A simple blob of python code to compute:

import numpy as np

schedule = [0.1, 0.1, 0.4, 0.4]

rsus = [500, 300, 400, 200]

print("Your yearly vesting is: ")

result = np.convolve(schedule,rsus)

print(result)

The result is:

Your yearly vesting is: 

[ 50.  80. 270. 380. 300. 240.  80.] 

References

  • GDB2024-001 PDF of this post 


Sunday, December 31, 2023

Gravitational lensing by an LLM

 A nice short article on gravitational lensing written by an LLM:

Title: Exploring the Cosmic Mirages: Gravitational Lensing

Introduction

In the vast expanse of the universe, where light and matter dance together in the cosmic ballet, there exists a phenomenon that has captivated astronomers and astrophysicists for decades: gravitational lensing. This mesmerizing effect, first predicted by Albert Einstein in his theory of general relativity, has revolutionized our understanding of the cosmos and unveiled hidden secrets about distant galaxies and the nature of gravity itself.


The Essence of Gravitational Lensing

Gravitational lensing is a consequence of Einstein's theory of general relativity, which describes how massive objects warp the fabric of spacetime around them. When light from a distant object passes close to a massive celestial body, such as a galaxy or a black hole, the gravitational field of the massive object bends the path of the light, creating a lens-like effect. This phenomenon allows us to see multiple images of a single distant object, creating captivating cosmic mirages.


Types of Gravitational Lensing

There are several types of gravitational lensing, each offering unique insights into the universe:

1. Strong Lensing: In strong lensing, the gravitational field of a massive object is so strong that it distorts and magnifies the background object into multiple distinct images. This effect often results in the formation of strikingly beautiful, concentric rings known as Einstein rings or gravitational arcs.

2. Weak Lensing: Weak lensing occurs when the gravitational field is not strong enough to produce multiple images but instead slightly distorts the shape of the background object. By studying these subtle distortions, astronomers can map the distribution of dark matter and measure the mass of galaxy clusters, shedding light on the mysterious dark side of the universe.

3. Microlensing: Microlensing involves smaller, less massive objects acting as gravitational lenses. This phenomenon has been instrumental in the discovery of exoplanets by detecting the brief brightening of a background star when an exoplanet passes in front of it.


Applications and Discoveries

Gravitational lensing has become an indispensable tool in modern astrophysics. Some of its notable applications and discoveries include:

1. Dark Matter Mapping: By studying the weak gravitational lensing effects on background galaxies, astronomers have mapped the distribution of dark matter in galaxy clusters, revealing the invisible scaffolding that shapes the cosmos.

2. Cosmic Magnifying Glass: Strong gravitational lensing can magnify distant galaxies, allowing astronomers to observe objects that would otherwise be too faint to detect. This technique has led to the discovery of some of the most distant galaxies known to science.

3. Measuring Cosmic Expansion: Gravitational lensing can also help measure the Hubble constant, a fundamental parameter describing the rate of cosmic expansion. This has important implications for our understanding of the age and fate of the universe.


Conclusion

Gravitational lensing is a remarkable phenomenon that has opened a new window into the cosmos. It allows us to peer into the depths of space and time, revealing hidden galaxies, dark matter, and the true nature of gravity. As our understanding of gravitational lensing continues to deepen, we can look forward to even more astonishing discoveries that will reshape our understanding of the universe and our place within it. This cosmic mirage reminds us that the universe is full of wonders, waiting to be unveiled by the curious eyes of science.

Wednesday, April 19, 2023

Anycast IP addresses and their use in DNS servers

What are Anycast IP addresses?
Multiple servers having the same IP addresses. The routers pick the closest server with the least BGP hops.

How are Anycast IP addresses implemented?
Anycast is simply that the same network is advertised from multiple places. A router receiving multiple advertisements for the same network will choose which advertisement to place in its routing table based on the metrics of the routing protocol. This results in the closest (from the perspective of the routing protocol metrics) destination being used by a router.

Why use Anycast IP addresses for DNS servers?
Excerpt from [1]:
With Unicast, DNS client resolvers can be configured with multiple DNS name server targets. In the event the resolver doesn't receive any response from the first server on the list, it will typically wait a time out value, before it switches to the second server (and subsequent servers) in the resolver list. The next time the resolver has to perform a look up, it won't "remember" servers in the list were non-responsive, and it will start querying with the first server in the list even though it is still unavailable.  Depending on the operating system of the client, it could be one to five seconds as it rotates through the resolver list each time, attempting the failed server.  

With anycast DNS IP addresses, this delay is eliminated and handled by the routing protocol.

References
 

Friday, March 17, 2023

Difference between ramdisk (e.g. initramfs) and loopback device filesystem

My interpretation. Both are types of virtual ramdisks. 
  • Ramdisk uses memory (non-swappable) as a virtual device, while a loopback device uses a file (IF=input_file) as the input. dd if=file_name > of=/dev/loop, then we mount -o loop /dev/loop /mnt
  • The loopback filesystem associates a file on another filesystem as a complete device. For Ramdisks, the device does not refer to any physical hardware, but to a portion of memory that is set aside for the purpose.
  • Loopback vs Ramdisks. During boot - The initial ramdisk device in Linux is another important mechanism that we need to be able to use a loopback device as a the root filesystem.
  • Using Losetup script in Linux to create a disk image.
    • Create an empty image, use losetup to associate that with a loopback device that is not in use (check losetup -a), mkfs to create a file system, mount to /mnt, copy desired files to /mnt, umount /mnt, losetup -d to detach the loopback device from the file.