Home Subscribe

1. Random Process

  • It is better to think of a random process in terms of a function rather than a variable.

  • In a random function, say, random(x), \(x\) is the sample space of random outcomes that are possible after performing a certain stochastic process such as tossing a fair coin.

  • Let’s say we are tossing a pair of coins. The outcome does not have to be a number. It can be heads or tails. However, the number of possible outcomes lies in a certain range, say, range(x).

\[\begin{align*} \text{random}(x) &= \begin{cases} \text{Coin 1} &= [H, H, T, T]\\ \text{Coin 2} &= [H, T, H, T] \end{cases} \\ \text{range}(x) &= [1, 2, 3, 4] \end{align*}\]
  • \(x\) outputs an outcome from range(x) using a probability distribution that represents a likelihood of occurrences of events within the sample space.

  • In the above coin-tossing experiment, the sum of the probabilities of all outcomes should add up to 1 because a coin toss will always yield some output.

\(P_{\text{1 or 2 or 3 or 4}} = P_1 + P_2 + P_3 + P_4 = 1\)

  • \(x\) can be discrete or continuous.

1.1. Discrete random variable

  • A discrete random variable can take distinct or separate values.

  • Discrete random variable is countably infinite

  • A coin toss

\[x = \begin{cases} Head &= [1]\\ Tail &= [0] \end{cases}\]
  • The year that a random student in a school was born

  • The number of mosquitos born yesterday on earth

  • Winning time of random athletes to the nearest 2 decimals

  • The number of cars passing at a certain junction at a certain time

  • A discrete random variable can be countable finite or approach infinite values. At least you can list a few specific values.

  • The probability distribution of a discrete random variable is called Probability Mass Function (PMF)

1.2. Continuous random variable

  • A continuous random variable can take any value in an interval.

  • Continuous random variable is uncountably infinite

\[x = \begin{cases} \textbf{Exact mass}\text{ of random organisms on earth} \end{cases}\]
  • Even if you could find a range of this mass, the exact mass of a certain organism at a given time could have several decimal points…​

  • Precisely exact winning time of random athletes

  • Temperature of a random place in a year measured at a high precision

  • A real-world example of a true case of a continuous random variable is rare.

  • A continuous random variable can be uncountable infinite values. You cannot list a few specific values.

  • The probability distribution of a continuous random variable is called Probability Density Function (PDF)

  • Each variable can take on a different value from a probability distribution.

  • A random process can be discrete or continuous depending on whether its member variables are discrete or continuous.

1.3. Gambler’s Ruin

Idea

Example 1

A gambler has KES 500. They can only bet in increments of KES 100. They can only win or lose KES 100 per bet. They will keep gambling until they either lost all their money (KES 0) or win KES 1000. Simulate this gambling situation.

Solution:
\[\text{gambling outcome, } x = \begin{cases} \text{Win KES 100 (P = 50%)} &= [+100] \\ \text{Lose KES 100 (P = 50%)} &= [-100] \end{cases}\]
 1import numpy as np
 2import random 
 3import matplotlib.pyplot as plt 
 4
 5def gamble():
 6    start_money = 500
 7    win_money = 1000
 8    bet_size = 100
 9    win_lose = 100
10    gambling_range = range(win_lose,win_money)
11    simul_gamble = []
12    while start_money in gambling_range:
13        win_lose = bet_size*random.randrange(-1, 2, step=2)
14        start_money += win_lose 
15        simul_gamble.append(start_money)
16    return simul_gamble 
17
18plt.plot(gamble(), marker = 'o')
19plt.xlabel("Gambling Events"); plt.ylabel("Win or Lose")
20plt.savefig("../images/gamblers_ruin.png")
21plt.show()
gamblers-ruin
Figure 1. Gambler’s ruin output.


Add Comment

* Required information
1000
Drag & drop images (max 3)
Out of 56, 14 or 27, which is the smallest?

Comments

No comments yet. Be the first!