BL40A2030 Wireless Communication Networks
Week 1: Introduction to Jupyter NB
Author: Pedro Nardelli
References
Markdown syntax for writing in the notebook
Library for numerical calculation in Python
Plot in pyhton
This first cell imports the libraries to be used in the tutorial. Everytime that you use a command related to numpy you need to use a np.. Likewise, whenever you call a command from matplotlib you use plt..
We call a plot style so every plot has a default template and another library is to cut the warning messages (usually annoying).
Basic commands
- Define a vector with timesteps
- Compute a sine and a cosine using this time steps
- Plot it
Try yourself:
- Plot: $e^{-t}$ and $\log_2 t$
- Use $t$ between 0 and 4 with 100 steps
Experiments using random variables
Let us make a computer experiment to simulate when someone throws a coin.
Defining the function of throwing the coin
In this case $p$ is the probability of being Head, so that Tail is $1-p$. If $p=0.5=50\%$, this is a fair coin, otherwise is a biased coin.
- Experiment 1: 1 trial
- Experiment 2: 10 trials
- Experiment 3: 10000 trials
- Get from experiment 3 the frequency that H and T appears
- Compare this with the bias probability
Try yourself:
- set $p=0.85$ and $p=0.05$
- run the experiments and check what happens
Generate Poisson random variables
- Not explaining what is a Poisson random variable now
- The idea is that during a fixed period of time, discrete events happens
- The number of events in each period is independent
- The only parameter needed is the expected value of how many packets will arrive in a given period
- First experiment: We will generante an array with 10 numbers with mean of 4 packets per period.
- Second experiment: Array with 10000 with means 2 and 4 and draw a histogram
Example of simple queue
- Packets or persons arrive following a Poisson distribution with mean $\lambda$ in a given period of time
- Packets or persons that have arrived service rate follows a Poisson distribution with mean $\mu$
- Can you tell what is the worst case in relation to delay?
Case 1: Arrivals smaller than service rate
Case 2: Arrivals greater than service rate
Case 3: Arrivals equal to service rate
Try yourself as follows:
- $\lambda = 1$ and $\mu = 1.1$
- $\lambda = 1.1$ and $\mu = 1$
To think about
What if:
- The queue has a maximum value (overflow)?
- If some packets are served in error and can be restransmitted?