> ## 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.

# Expected Value and Variance

The **expected value** of a random variable is the sum over all elements in a sample space of the product of the probability of the element and the value of the random variable at this element

> Nilai harapan dari variabel acak adalah jumlah dari semua elemen dalam ruang sampel dari hasil kali probabilitas elemen dan nilai variabel acak pada elemen ini

→ The expected value is a weighted average of the values of a random variable

> Nilai harapan adalah rata-rata tertimbang dari nilai variabel acak

The **expected value**, also called the expectation or mean, of the
random variable $X$ on the sample space $S$ is equal to

> Nilai harapan, juga disebut ekspektasi atau rata-rata, dari variabel acak $X$ pada ruang sampel $S$ sama dengan

<Note>
  $~~~~~ E(X) = \sum_{s \in S} p(s) \cdot X(s)$
</Note>

The ***deviation*** of $X$ at $s \in S$ is $X(s) - E(X)$, the difference
between the value of $X$ and the mean of $X$.

> ***Deviasi*** dari $X$ pada $s \in S$ adalah $X(s) - E(X)$, perbedaan antara nilai $X$ dan rata-rata $X$.

### Example

<Card>
  Let X be the number that comes up when a fair die is rolled.
  What is the expected value of X?

  <br />

  Solution:

  The random variable X takes the values 1, 2, 3, 4, 5, or 6,
  each with probability $\dfrac{1}{6}$.

  <br />

  It follows that

  $~~~~~ E(X) = \sum_{s \in S} p(s) \cdot X(s)$

  <br />

  $~~~~~~~~~~~~~~~~ = \dfrac{1} {6} \cdot 1 + \dfrac{1} {6} \cdot 2 + \dfrac{1} {6} \cdot 3 + \dfrac{1} {6} \cdot 4 + \dfrac{1} {6} \cdot 5 + \dfrac{1} {6} \cdot 6 = \dfrac{21} {6} = \dfrac{7} {2}$.
</Card>

<Card>
  A fair coin is flipped three times. Let S be the sample space
  of the eight possible outcomes,and let X be the random
  variable that assigns to an outcome the number of heads in
  this outcome. What is the expected value of X?

  <br />

  Solution:

  Because the coin is fair and the flips are independent, the
  probability of each outcome is $\dfrac{1}{8}$.

  <br />

  It follows that

  $~~~~~ E(X) = \dfrac{1}{8} [X(HHH) + X(HHT) + X(HTH) + X(THH) + X(TTH)$
  $~~~~~~~~~~~~~~~~~~~~~~~~~~ + X(THT) + X(HTT) + X(TTT)]$

  <br />

  $~~~~~~~~~~~~~~~~ = \dfrac{1} {8} [3 + 2 + 2 + 2 + 1 + 1 + 1 + 0] = \dfrac{12} {8} = \dfrac{3} {2}$.
</Card>

### Theorem 2

If $X$ is a random variable and $p(X = r)$ is the probability
that $X = r$, so that $p(X = r) = \sum_{s \in S: X(s) = r} p(s)$,
then

> Jika $X$ adalah variabel acak dan $p(X = r)$ adalah probabilitas bahwa $X = r$, sehingga $p(X = r) = \sum_{s \in S: X(s) = r} p(s)$, maka

<Note>
  $~~~~~ E(X) = \sum_{r \in X(S)} p(X = r) \cdot r$
</Note>

### Theorem 3

The expected number of successes when $n$ mutually
independent Bernoulli trials are performed, where $p$ is
the probability of success on each trial, is $np$.

## Variance

Let $X$ be a random variable on a sample space $S$. The
variance of $X$, denoted by $V(X)$, is

> Biarkan $X$ menjadi variabel acak pada ruang sampel $S$. Varians dari $X$, dilambangkan dengan $V(X)$, adalah

<Note>
  $~~~~~ V(X) = \sum_{s \in S} [X(s) - E(X)]^2 \cdot p(s)$
</Note>

That is, $V(X)$ is the weighted average of the square of the
deviation of $X$.

> Artinya, $V(X)$ adalah rata-rata tertimbang dari kuadrat deviasi $X$.

The standard deviation of $X$, denoted $\sigma(X)$, is defined to be $\sqrt{V(X)}$.

### Theorem 4

If $X$ is a random variable on a sample space $S$, then

> Jika $X$ adalah variabel acak pada ruang sampel $S$, maka

<Note>
  $~~~~~ V(X) = E(X^2) - E(X)^2$
</Note>
