# Conditional Probability

{% hint style="success" %}
Conditional probability is the likelihood of an event A to occur given that another event that has a relation with event A has already occurred.
{% endhint %}

Suppose that we have 6 blue balls and 4 yellows placed in two boxes as seen below. I ask you to randomly pick a ball. The probability of getting a blue ball is 6 / 10 = 0,6. What if I ask you to pick a ball from box A? The probability of picking a blue ball clearly decreases. The condition here is to pick from box A which clearly changes the probability of the event (picking a blue ball). The probability of event A given that event B has occurred is denoted as p(A|B).

![](/files/-MPs-sNQYMlwLIBL4Sd9)

$$
P(A|B) = \frac {P(A,B)}{P(B)} = \frac {P(A \cap B)}{P(B)}
$$

### Example

{% hint style="info" %}
In a group of 100 sports car buyers, 40 bought alarm systems, 30 purchased bucket seats, and 20 purchased an alarm system and bucket seats. If a car buyer chosen at random bought an alarm system, what is the probability they also bought bucket seats?
{% endhint %}

Here, P(B) = Probability of a car buyer chosen at random bought an alarm system, which is 40/100 = 0.4\
P(A,B) = Probability of both happening together, which is given 20/100 = 0.2\
So, P(A|B) = 0.2/0.4 = 0.5


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ai.nuhil.net/probability/conditional-probability.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
