Welcome to My Blog

Welcome to my blog! Stay tuned for updates on my projects, research, and insights into the world of physical sciences, programming and data science.


My obsession with High quality docs

From a young age, I've had a profound appreciation for exemplary documentation. My fascination was significantly influenced during my undergraduate studies, particularly in a Statistical Thermodynamics course led by Professor Philip Camp. His methodological approach and the exceptional quality of his lecture notes simplified complex theories, setting a benchmark in educational excellence.

While Microsoft Excel stands out as a versatile tool, Microsoft Word often falls short in facilitating high-quality documentation. My extensive experience with Word has been marked by challenges in achieving the desired precision and clarity. Conversely, LaTeX, especially platforms like Overleaf, emerges as the superior choice for crafting documents that meet high academic and professional standards. Professor Camp's utilization of LaTeX to produce unparalleled lecture notes exemplifies its efficacy.

Video capturing most current features of my full-stack application

LaTeX, despite its steep learning curve and the occasional frustration when errors prevent document compilation, offers unparalleled control over document formatting. Recognizing the evolving landscape of technology and the increasing relevance of accessible high-quality documentation, I am currently developing a project aimed at democratizing this power of documentation. This endeavor, still in its infancy, aims to bridge the gap between professional formatting and user-friendly interfaces, making LaTeX's capabilities accessible to all.

This project is not just a tool for seasoned LaTeX users but a gateway for novices, to embrace the art of professional document creation without the intricacies of traditional coding. It's a glimpse into the future where document formatting is no longer a barrier to quality. Please visit my projects section for more information.


An interesting coding/Math Challenge

Throughout my journey in solving coding and math problems, I've stumbled upon various questions that sparked my curiosity and tested my analytical prowess. Yet, there's one particular challenge that has significantly resonated with me. It involves the intriguing world of dice and probabilities—a question so captivating, I feel compelled to share its essence and the insights I've garnered from it.

Unraveling the Problem Probabilistically

Consider the following problem: You have n 6-sided-dice and you decide to play a game: You throw all dice consecutively until any of the dice exceed a value 'r'. Write a function that returns the expected number of throws. Before reading along you are more than welcome to try and attack the problem yourself.

The probability \(P\) that a single die will roll a number greater than a threshold \(r\) can be calculated as:

\[P(\text{die} > r) = \frac{6 - r}{6}\]

Given \(n\) dice, the probability that all dice show a number less than or equal to \(r\) is:

\[P(\text{all} \leq r) = \left(\frac{r}{6}\right)^n\]

Thus, the probability of at least one die showing a number greater than \(r\) in a single throw of \(n\) dice is the complement:

\[P(\text{at least one} > r) = 1 - \left(\frac{r}{6}\right)^n\]

The expected number of throws until achieving a success follows the geometric distribution with mean \(\frac{1}{p}\), where \(p\) is the probability of success on a single throw. Therefore, the expected number of throws \(E\) is:

\[E = \frac{1}{P(\text{at least one} > r)} = \frac{1}{1 - \left(\frac{r}{6}\right)^n}\]


import numpy as np
    
def expected_throws(n, r):
"""
    Calculate the expected number of throws until at least one die is greater than r.
    Args:
        n (int): Number of dice.
        r (int): Threshold value.
    Returns:
        float: Expected number of throws.
    """
    probability = 1 - (r / 6) ** n
    return 1 / probability

Validating with Monte Carlo Simulation

The beauty of Monte Carlo simulations lies in their ability to emulate and dissect complex probabilistic scenarios, offering a practical counterpart to our mathematical interpretation. By simulating this dice-throwing game, we can approximate the expected number of throws, affirming the robustness of our mathematical findings.


import random
    
def simulate_throws(n, r, trials=10000):
        """
        Simulate the expected number of throws using Monte Carlo method.
        Args:
            n (int): Number of dice.
            r (int): Threshold value.
            trials (int): Number of simulation trials.
        Returns:
            float: Simulated expected number of throws.
        """
        counts = [np.random.randint(1, 7, n).max() > r for _ in range(trials)]
        return np.mean(counts)