@abhi_singhal See if this helps.
Try screaming on the soup,
"You are an ice cream, you are an ice cream."
If it's still not ice cream, you are not screaming enough... 😅😆
There are frequent debates in India about what exactly forced the British to grant us Independence in 1947. It was a combination of factors that included a war-weary Britain, and the long-running political mobilisation in India. However, the fear of guerrilla warfare by the revolutionaries, and the possibility of a revolt in the Indian armed forces (esp after INA & Naval revolt) played a major role. We do not need to debate this because Prime Minister Attlee has explicitly noted this in the Transfer of Power papers (Nov 1946). Just look up Vol 9, doc 35, page 68 (199 in the pdf):
https://t.co/yvIioo0zl7
My girlfriend borrowed some money from me saying it was for her mother’s medical emergency. Turns out she used it to go on a trip with another guy.
I found hotel bookings and flight confirmations. Instead of confronting her, I planned to send the evidence to her family group chat.
But when I finally did it, her family’s reaction wasn’t what I expected. Instead of being outraged with her, they defended her, saying “relationships are complicated” and “maybe you drove her to it.”
They weren’t just defending her. They were behaving like conditional probability without updating on new evidence, violating Bayes’ Theorem.
In Bayes Theorem, you start with a prior belief and update it when you see new evidence. You don’t just ignore the data.
Formula
P(H | E) = (P(E | H) × P(H)) / P(E)
Where
H: Hypothesis
E: Evidence (what you observe)
P(H): Prior probability
P(E): Probability of the evidence
P(E | H): Prob. of the E if the H is true
P(H | E): Prob. of the H given that the E is observed
Let’s take an example and solve it step by step.
In a box, there are only red balls and blue balls.
- 70% of the balls are red
- 30% of the balls are blue
Some balls are large: the probability that a ball is large is 0.2 if it is red and 0.6 if it is blue.
A ball is picked at random and is found to be large. Find the probability that the ball is red.
Step 1: Define hypotheses
- H1: the ball is red
- H2: the ball is blue
Step 2: Define evidence
- E: the ball is large
Step 3: Define prior probabilities
- P(H1) = 0.7
- P(H2) = 0.3
Step 4: Calculate likelihoods
- P(E | H1) = 0.2
- P(E | H2) = 0.6
Step 5: Calculate total probability of the evidence
P(E) = P(E | H1)·P(H1) + P(E | H2)·P(H2)
P(E) = (0.2)(0.7) + (0.6)(0.3)
P(E) = 0.14 + 0.18
P(E) = 0.32
So overall, 32% of balls are large.
Step 6: Apply Bayes Theorem
- P(H1 | E) = (P(E | H1)·P(H1)) / P(E)
- P(H1 | E) = 0.14 / 0.32
- P(H1 | E) = 0.4375
Final answer
If the ball is large, the probability that it is red is 43.75%.
Congratulations, you’ve just learned Bayes Theorem!
Bonus: Applications of Bayes Theorem in AI/ML
1. Recommendation systems:
Bayesian methods estimate P(User likes a movie | viewing history) by updating prior preferences based on observed behavior.
2. Spam filters:
Email classifiers estimate P(Spam | words in an email) using word likelihoods learned from data.
3. Medical diagnosis:
Diagnostic systems estimate P(Disease | symptoms) by combining disease prevalence with symptom likelihoods.
4. A/B testing:
Bayesian A/B testing updates beliefs about which variant performs better as data accumulates.
5. Reinforcement learning:
Bayesian approaches maintain probability distributions over models of the environment and update them as the agent gathers experience.
If you want to get started coding in C++, setting up your development environment can be challenging.
And you'll need to know how to manage dependencies, automate builds, collab using version control, & use AI tools.
In this course, you'll learn how to set up a professional-grade C++ dev environment using tools like CMake, vcpkg, Docker & Copilot.
https://t.co/lBy0G2JZxB
I’m European.
Last year, I moved to India.
What I experienced shattered my Western mindset.
Here are 10 life-changing lessons I learned in India that reshaped how I see the world:
How do we Perform Pagination in API Design?
Pagination is crucial in API design to handle large datasets efficiently and improve performance. Here are six popular pagination techniques:
🔹 Offset-based Pagination:
This technique uses an offset and a limit parameter to define the starting point and the number of records to return.
- Example: GET /orders?offset=0&limit=3
- Pros: Simple to implement and understand.
- Cons: Can become inefficient for large offsets, as it requires scanning and skipping rows.
🔹 Cursor-based Pagination:
This technique uses a cursor (a unique identifier) to mark the position in the dataset. Typically, the cursor is an encoded string that points to a specific record.
- Example: GET /orders?cursor=xxx
- Pros: More efficient for large datasets, as it doesn't require scanning skipped records.
- Cons: Slightly more complex to implement and understand.
🔹 Page-based Pagination:
This technique specifies the page number and the size of each page.
- Example: GET /items?page=2&size=3
- Pros: Easy to implement and use.
- Cons: Similar performance issues as offset-based pagination for large page numbers.
🔹 Keyset-based Pagination:
This technique uses a key to filter the dataset, often the primary key or another indexed column.
- Example: GET /items?after_id=102&limit=3
- Pros: Efficient for large datasets and avoids performance issues with large offsets.
- Cons: Requires a unique and indexed key, and can be complex to implement.
🔹 Time-based Pagination:
This technique uses a timestamp or date to paginate through records.
- Example: GET /items?start_time=xxx&end_time=yyy
- Pros: Useful for datasets ordered by time, ensures no records are missed if new ones are added.
- Cons: Requires a reliable and consistent timestamp.
🔹 Hybrid Pagination:
This technique combines multiple pagination techniques to leverage their strengths.
Example: Combining cursor and time-based pagination for efficient scrolling through time-ordered records.
- Example: GET /items?cursor=abc&start_time=xxx&end_time=yyy
- Pros: Can offer the best performance and flexibility for complex datasets.
- Cons: More complex to implement and requires careful design.
–
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://t.co/uc5M7CdXXC
𝗦𝗵𝗼𝘂𝗹𝗱 𝘆𝗼𝘂 𝘀𝘁𝗼𝗽 𝘂𝘀𝗶𝗻𝗴 𝗨𝗨𝗜𝗗𝘀?
UUIDs (Guid in C#) are widely used as unique identifiers in databases. UUIDs are random, which makes them popular in distributed systems.
However, UUIDs have some drawbacks:
1. UUIDs slow down database inserts. Each insert must update the clustered index, a B+ tree. Because UUIDs are random, this is an expensive operation as it requires rebalancing the tree
2. Higher storage costs. A UUID is 128 bits long, and it's even longer if you store it in human-readable format as a string.
So, let me introduce you to ULIDs.
ULID attempts to solve the drawbacks of UUID. It's also 128-bit, so it's compatible with a UUID. However, unlike a UUID, ULIDs are sortable. The first 40 bits of a ULID represent a timestamp, making ULIDs monotonically increasing.
There's a .NET package that implements the ULID spec, so you can start using it immediately. However, you'll need to write some code if you want ULID to work with popular ORMs.
What do you think about ULIDs?
---
Subscribe to my weekly newsletter to accelerate your .NET skills: https://t.co/tLCs0ytX2R