> ## Documentation Index
> Fetch the complete documentation index at: https://v1-learn.neoartd.my.id/llms.txt
> Use this file to discover all available pages before exploring further.

# Bernoulli Trials and the Binomial Distribution

## Bernoulli Trial

Each performance of an experiment with two possible outcomes is called a **Bernoulli trial**.

> Setiap pelaksanaan percobaan dengan dua kemungkinan hasil disebut **percobaan Bernoulli**.

In general, a possible outcome of a Bernoulli trial is called a `success` or a `failure`.

> Secara umum, hasil yang mungkin dari uji coba Bernoulli disebut `sukses` atau `gagal`.

If **p is the probability of a success** and **q is the probability of a failure**, it follows that `p + q = 1`.

> Jika **p adalah probabilitas sukses** dan **q adalah probabilitas kegagalan**, maka `p + q = 1`.

### Theorem

<Card>
  The probability of exactly k successes in n independent
  Bernoulli trials, with probability of success p and
  probability of failure $q = 1 - p$, is

  <Tip>
    Probabilitas tepat k keberhasilan dalam n uji coba Bernoulli independen,
    dengan probabilitas keberhasilan p dan probabilitas kegagalan $q = 1 - p$,
    adalah
  </Tip>

  **$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C(n, k) p^k q^{n-k}$**
</Card>

### Example 1

<Card>
  A coin is biased so that the probability of heads is 2/3. What is the
  probability that exactly four heads come up when the coin is flipped seven
  times, assuming that the flips are independent?

  <Tip> Koin bias sehingga
  probabilitas kepala adalah 2/3. Berapa probabilitas bahwa tepat empat kepala
  muncul ketika koin dibalik tujuh kali, dengan asumsi bahwa koin dilempar
  secara bebas? </Tip>
  **Solution:**

  <Check>
    * There are $2^7 = 128$ possible outcomes when a coin is flipped seven times.
    * The number of ways four of the seven flips can be heads is $C(7, 4)$.
    * Because the seven flips are independent, the probability of each of these outcomes (four heads and three tails) is $(2/3)^4 (1/3)^3$.
    * Consequently, the probability that exactly four heads appear is

    <br />

    * $C(7, 4) (\dfrac{2}{3})^4 (\dfrac{1}{3})^3 = \dfrac{35 \times 16}{3^7} = \dfrac{560}{2187} \approx 0.256$.
  </Check>
</Card>

## Binomial Distribution

We denote by *$b(k; n, p)$* the probability of k successes in n independent Bernoulli trials with probability of success p and probability of failure `q = 1 - p`.

> Kami menyatakan dengan *$b(k; n, p)$* probabilitas keberhasilan k dalam n percobaan Bernoulli independen dengan probabilitas keberhasilan p dan probabilitas kegagalan `q = 1 - p`.

Considered as a function of k, we call this function the **binomial distribution**

> Dianggap sebagai fungsi k, kita menyebut fungsi ini sebagai **distribusi binomial**

<Info>$b(k; n,p) = C(n,k) p^k q^{n - k}$</Info>

### Example 2

<Card>
  Suppose that the probability that a 0 bit is generated is 0.9, that
  the probability that a 1 bit is generated is 0.1, and that bits are
  generated independently. What is the probability that exactly
  eight 0 bits are generated when 10 bits are generated?

  <Tip> Misalkan probabilitas 0 bit dihasilkan adalah 0,9, probabilitas 1
  bit dihasilkan adalah 0,1, dan bit dihasilkan secara independen.
  Berapa probabilitas bahwa tepat delapan 0 bit dihasilkan ketika
  10 bit dihasilkan? </Tip>
  **Solution:**

  <Check>
    * By Theorem 2, the probability that exactly eight 0 bits are generated is

    <br />

    * $b(8; 10, 0.9) = C(10, 8) (0.9)^8 (0.1)^2 = 0.1937102445$.
  </Check>
</Card>

## Random Variables

A random variable is a function from the sample space of an experiment to the set of real numbers.

> Variabel acak adalah fungsi dari ruang sampel percobaan ke himpunan bilangan real.

A random variable assigns a real number to each possible outcome.

> Variabel acak memberikan bilangan real untuk setiap kemungkinan hasil.

The distribution of a random variable X on a sample space S is the set of pairs $(r, p(X = r))$ for all $r \in X(S)$, where $p(X = r)$ is the
probability that X takes the value r.

> Distribusi variabel acak X pada ruang sampel S adalah himpunan pasangan $(r, p (X = r))$ untuk semua $r \in X (S)$, di mana $p(X = r)$ adalah probabilitas bahwa X mengambil nilai r.

#### Example 3

<Card>
  * Suppose that a coin is flipped three times.
  * Let $X(t)$ be the random variable that equals the number of heads that appear when t is the outcome.
  * Then $X(t)$ takes on the following values:

  <Tip>
    $X(HHH) = 3,$\
    $X(HHT) = X(HTH) = X(THH) = 2,$\
    $X(TTH) ~= X(THT) = X(HTT) = 1,$\
    $X(TTT) ~~= 0.$
  </Tip>
</Card>

#### Example 4

<Card>
  Let $X$ be the sum of the numbers that appear when a pair of dice is rolled.
  What are the values of this random variable for the 36 possible outcomes
  $(i,j)$, where $i$ and $j$ are the numbers that appear on the first die and the
  second die, respectively, when these two dice are rolled?

  <Tip>
    Misalkan $X$ adalah jumlah angka yang muncul saat sepasang dadu dilempar.
    Berapa nilai variabel acak ini untuk 36 hasil yang mungkin $(i,j)$, di mana $i$
    dan $j$ masing-masing adalah angka yang muncul pada dadu pertama dan
    dadu kedua, ketika kedua dadu ini dilempar?
  </Tip>

  **Solution:**

  <Check>
    $X((1,1)) = 2,$\
    $X((1,2)) = X((2,1)) = 3,$\
    $X((1,3)) = X((2,2)) = X((3,1)) = 4,$\
    $X((1,4)) = X((2,3)) = X((3,2)) = X((4,1)) = 5,$\
    $...$
  </Check>
</Card>

### Distribution of Random Variable

The **distribution** of a random variable $X$ on a sample space
$S$ is the set of pairs $(r, p(X = r))$ for all $r \in X(S)$, where
$p(X = r)$ is the probability that $X$ takes the value $r$

The set of pairs in this distribution is determined by the
probabilities $p(X = r)$ for $r \in X(S)$

#### Example 5

<Card>
  Suppose that a coin is flipped three times. Let $X(t)$ be the random
  variable that equals the number of heads that appear when t is the
  outcome. Determine the distribution of $X(t)$.

  <Tip>
    Misalkan sebuah koin dilempar tiga kali. Misalkan $X(t)$ adalah
    variabel acak yang sama dengan jumlah kepala yang muncul ketika t
    adalah hasilnya. Tentukan distribusi $X(t)$.
  </Tip>

  **Solution:**

  <Check>
    Each of the eight possible outcomes when a fair coin is flipped three times has probability 1/8

    <br />

    $P(X = 3) = 1/8, P(X = 2) = 3/8, P(X = 1) = 3/8$, and $P(X = 0) = 1/8$

    <br />

    Consequently, the distribution of $X(t)$ is the set of pairs $(3,1/8)$, $(2,3/8)$, $(1,3/8)$, and $(0,1/8)$.
  </Check>
</Card>
