easy | probability |

Let $X$ be a random variable that takes value 0 or 1 with 50% probability each. You need to define a new random variable $Y$ as a function of $X$, such that $Y$ has the value 1 with 25% probability and 0 otherwise.

Use $X^\prime$ as an independent copy of $X$.

$Y = X * X^\prime$ where $X^\prime$ is an independent copy of $X$

Given $X$ is a random variable such that $P(X=1)=P(X=0)=0.5$.

These mathematical entities typically represent a real world concept. For example, this $X$ can take value 0 or 1 based on the outcome of a coin toss, say Tails representing 0 and Heads represeting 1. But we can toss this coin again, and get another sample independent of the first outcome. Let $X^\prime$ take the value 0 or 1 based on this second toss, independent of the first toss. This is the concept of an **independent copy**.

Let $X^\prime$ be an independent copy of $X$. It has the same probability distribution as $X$ but the value may or may not be the same.

Thus, $P(X=1) = P(X^\prime=1) = 0.5$

Also, we can imagine if one coin-toss has probability of 1/2 for a heads, then the probability will be 1/4 for both coins to show up heads.

$P(X=1, X^\prime=1) = P(X=1) * P(X^\prime=1) = 1/4$

Hence, we can define $Y$ = 1 if both $X$ and $X^\prime$ are 1, and 0 otherwise.

We can also use **product** operator to simplify this relationship.

$Y = X \cdot X ^\prime$

This way, if both $X$ and $X^\prime$ are 1 then $Y$ will be 1, otherwise zero.

This is not the same as $Z = X^2$ because $Z$ can take the value 0 or 1 with probability 50% each.

### Programming Variant

Following is the programming version of this question:

Function `f1()`

returns `true`

or `false`

with 50% probability each, define function `f2()`

that can return `true`

with 25% probability, and `false`

otherwise. You may use the function `f1`

.

This can be answered using the **and gate**.

```
def f2():
return f1() and f1()
```