vault backup: 2024-10-25 16:59:19

This commit is contained in:
Marco Realacci 2024-10-25 16:59:19 +02:00
parent 8adfbd51e6
commit 4224d57384
27 changed files with 131 additions and 55 deletions

View file

@ -7,50 +7,20 @@
"id": "92983280ad25c0d4",
"type": "tabs",
"children": [
{
"id": "ecad7b7424be569c",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "q&a.md",
"mode": "source",
"source": false
},
"icon": "lucide-file",
"title": "q&a"
}
},
{
"id": "ba82a2242fc4a714",
"type": "leaf",
"state": {
"type": "markdown",
"type": "image",
"state": {
"file": "Autonomous Networking/notes/7 RL.md",
"mode": "source",
"source": false
"file": "Foundation of data science/images/Pasted image 20241025161824.png"
},
"icon": "lucide-file",
"title": "7 RL"
}
},
{
"id": "6540571933182903",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "conflict-files-obsidian-git.md",
"mode": "source",
"source": false
},
"icon": "lucide-file",
"title": "conflict-files-obsidian-git"
"icon": "lucide-image",
"title": "Pasted image 20241025161824"
}
}
],
"currentTab": 2
"stacked": true
}
],
"direction": "vertical"
@ -206,23 +176,26 @@
"obsidian-git:Open Git source control": false
}
},
"active": "6540571933182903",
"active": "5d5551c2fd0314c8",
"lastOpenFiles": [
"Foundation of data science/images",
"Foundation of data science/notes/Logistic Regression.md",
"Foundation of data science/images/Pasted image 20241025165411.png",
"Foundation of data science/images/Pasted image 20241025165317.png",
"Foundation of data science/images/Pasted image 20241025165130.png",
"Foundation of data science/images/Pasted image 20241025163314.png",
"Foundation of data science/images/Pasted image 20241025163040.png",
"Foundation of data science/images/Pasted image 20241025162426.png",
"Foundation of data science/images/Pasted image 20241025162234.png",
"Foundation of data science/images/Pasted image 20241025162152.png",
"Foundation of data science/images/Pasted image 20241025161824.png",
"Autonomous Networking/images/Pasted image 20241025092932.png",
"Autonomous Networking/notes/2 RFID.md",
"Autonomous Networking/notes/q&a.md",
"Autonomous Networking/notes/3 WSN MAC.md",
"Autonomous Networking/notes/8.md",
"Autonomous Networking/notes/7 RL.md",
"conflict-files-obsidian-git.md",
"Biometric Systems/images/Pasted image 20241024100002.png",
"Biometric Systems/images/Pasted image 20241024095704.png",
"Biometric Systems/images/Pasted image 20241024094223.png",
"Biometric Systems/images/Pasted image 20241024093000.png",
"Biometric Systems/images/Pasted image 20241024092903.png",
"Biometric Systems/images/Pasted image 20241024092146.png",
"Biometric Systems/images/Pasted image 20241024091511.png",
"Biometric Systems/images/Pasted image 20241024091446.png",
"Biometric Systems/images/Pasted image 20241024091433.png",
"Biometric Systems/images/Pasted image 20241024091235.png",
"q&a.md",
"Autonomous Networking/notes/3 WSN MAC.md",
"8.md",
"Autonomous Networking/slides/AutonomousNet-Class11-2122-Performance_of_action_selection_methods_UCB.pdf",
"Biometric Systems/notes/4. Face recognition.md",
"Biometric Systems/slides/LEZIONE5_NEW_More about face localization.pdf",
@ -234,7 +207,6 @@
"Biometric Systems/slides/LEZIONE2_Indici_di_prestazione.pdf",
"Biometric Systems/notes/3. Recognition Reliability.md",
"Autonomous Networking/notes/4 WSN Routing.md",
"Autonomous Networking/notes/2 RFID.md",
"Foundation of data science/notes/1 CV Basics.md",
"Autonomous Networking/notes/5 Drones.md",
"Autonomous Networking/slides/5 Drones.pdf",
@ -252,7 +224,6 @@
"[[[LEZIONE2_Indici_di_prestazione.pdf.md",
"[LEZIONE2_Indici_di_prestazione.pdf.md",
"Biometric Systems/final notes/1. Introduction.md",
"Foundation of data science/slides/notes 2.md",
"Untitled.canvas"
]
}

View file

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View file

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View file

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View file

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View file

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -144,6 +144,7 @@ Often the number of tags in the system **is not known!**
- The total number of tags is estimated according to the outcome of the previous frame (based on Chebyshevʼs inequality)
![[Pasted image 20240928181304.png]]
I look for the n (number of tags) value that minimizes the difference!
Given N and a possible value of n, the expected number of slots with r tags is estimated as:
![[Pasted image 20240928181424.png]]

View file

@ -0,0 +1,54 @@
#### Q: explain the problem of energy consumption in sensor networks
As sensor run on batteries, energy consumption is a serious problem as we want sensors' batteries to last as long as possible. It's often challenging to replace or recharge the batteries.
Energy consumption is caused by a several things:
- overhearing
- overemitting
- idle listening
- collisions
- overhead caused by control packets
- continuous operation
- transmission distance
To achieve a low energy consumption is very important to define good MAC and routing strategies.
For MAC we can use protocols such as S-MAC, allows sensor to sleep most of the time when they are not communicating.
S-MAC works by letting sensors do the carrier sense only for a small fraction of the time while idle. To make this work, neighbor nodes needs to be synchronized to each-other, to be able to do carrier sensing at the same time. ecc.
#### Q: Challenges of routing in wireless sensor networks
routing protocols must be:
- scalable to support networks with very different sizes, and performance should not degrade increasing the size
- wide range of node density
- limited resources for each node
- low computation capability
- can not use too much energy
- nodes may even not have a global ID
- fault tollerant
- a node failure should not destroy the entire network
- support mobility as some nodes may be mobile
A good routing protocol should also guarantee that the network will have a long lifetime, as long as possible.
Energy consumption is very important as we seen before, for this reason, based on the needs, we can have different kind of routing protocols:
- proactive
- reactive
- geo-based
#### Q: Explain the difference between Framed Slotted Aloha and Tree Slotted Aloha protocols in RFID system
Both protocols are based on Slotted ALOHA: a frame is divided in time slots, and a tag randomly choses a slot to answer, in a way to reduce collisions.
In Frame Slotted Aloha, the number of slots in a frame is always the same. If two (or more) nodes decide to take the same slot, they create a collision. To try to address the collision, a new query is issued by the reader.
In TSA instead, for each collision slot s, a new child frame with a smaller slot number is issued. And only the tag that decided to transmit in slot s will transmit in the same frame.
The TSA protocol improves the system efficiency as the probability of having a collision is lower. But for both protocols, to have good performance is important to have an estimate of the number of tags to identify as we need to chose the number of slots based on it. If we have too many slots, we will have a lot of time wasted in idle slots, if we have too few slots, we will have a lot of collisions.
#### Q: in a slotted aloha protocol for RFID system how is the estimated tag population participating into intermediate frames?
Main issues:
- total number of tags to identify is not known
- initial frame size is set to a predefined value (e.g. 128)
- the size of the following frames is estimated by:
$$tags\_per\_collision\_slot=\frac{(estimated\_total\_num\_of\_tags) - (identified\_tags)}{collision\_slots}$$
The key issue is that we don't know the total number of tags! We can estimate it with the Chebyshev inequality. The problem is that for very large tag number, it can be inaccurate.
#### Q: explain the binary splitting protocol for RFID systems (discuss its performance)
All the tags have a counter set initially to 0. When the reader sends the first query every tag responds.
Every time a collision is generated, rags randomly increments their counter. The process repeat until a single tag or no tag responds. In this case all tags will decrement the counter.
As each time the tags are split into two sets, we can "see" it as a binary tree, so we can count the node of the tree to get an estimation.
$$BS_{tot}(n)=\begin{cases}1,n\le1\\ 1+\sum_{k=0}^{n}\binom{n}{k}\left(\frac12\right)^{k}\left(1-\frac12\right)^{n-k}\left(BS_{tot}\left(k\right)+BS_{tot}\left(n-k\right)\right),n>1\end{cases}$$
#### Q: explain the differences between proactive and reactive routing in sensor networks. Discuss the advantages and disadvantages

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View file

@ -0,0 +1,54 @@
La regressione logistica è una tecnica di machine learning fondamentale e ampiamente utilizzata per risolvere problemi di classificazione binaria. A differenza della regressione lineare, che è più adatta per problemi di previsione continua, la regressione logistica si focalizza sulla previsione di classi distinte, trasformando un input continuo in una probabilità, grazie alla funzione sigmoide: $$\sigma(z) = \frac{1}{1+e^{-z}}$$
![[Pasted image 20241025161824.png]]
Ipotizziamo di avere la seguente situazione, per valori bassi della nostra variabile x, tutti i sample hanno classe 0, viceversa per valori alti. Ma per valori intermedi abbiamo sia sample nella classe 0 che nella classe 1.
![[Pasted image 20241025162426.png]]
La funzione sigmoide nel grafico a destra rappresenterà quindi la ***probabilità di cadere nella classe 1***.
La regressione logistica è una tecnica per trovare una "linea ondulata" ottimale che rappresenta la probabilità di appartenere alla Classe 1 per vari valori della variabile. Ogni punto su questa linea indica la probabilità (p) di appartenere alla classe: i punti in basso hanno probabilità zero (p=0), mentre quelli in alto raggiungono la probabilità massima (p=1). La funzione logistica (es. la sigmoide, ma un altro esempio è la softmax) mappa valori da uno spazio infinito (-∞, +∞) a uno spazio probabilistico [0,1]. Al contrario, la funzione logit può trasformare lo spazio delle probabilità [0,1] in uno spazio che si estende da (-∞, +∞).
$$logit(p)=log\left(\frac{p}{1-p}\right)$$
![[Pasted image 20241025163040.png]]
Trasformare lo spazio [0,1] in (-∞, +∞) rende il problema simile a una regressione lineare, facilitando l'ottimizzazione. La ricerca della linea ottimale parte da una retta iniziale nello spazio logit variabile, con l'obiettivo di regolarne i coefficienti per massimizzare la verosimiglianza.
Per una variabile, l'equazione è: $$\text{logit}(p) = \log \left( \frac{p}{1 - p} \right) = \beta_0 + \beta_1 \cdot v$$
L'obiettivo è adattare la retta ai punti dati nel grafico _logit vs variabile_ in modo che, una volta trasformata nella curva ondulata tramite l'inversa della funzione logit, separi il maggior numero di punti tra le classi. Per fare questo, si utilizza una strategia simile alla regressione lineare, ma invece di minimizzare i residui quadrati (mean squared error), si massimizza la likelihood.
Procediamo nel seguente modo:
- scegliamo dei valori arbitrari per definire una linear regression iniziale
- proiettiamo i punti sulla retta. Applicando la funzione logistica otteniamo una roba tipo quella che si vede nel terzo grafico
![[Pasted image 20241025163314.png]]
Pensandoci, possiamo rappresentare le probabilità con questa equazione:
$$P(Y=y | X;\theta)=\sigma(\beta^Tx)^y[1-\sigma(\beta^Tx)]^{1-y}$$
e se ci facciamo caso è praticamente una distribuzione di Bernoulli. Si legge come: la probabilità che Y sia y (che ricordiamo, può essere 0 oppure 1), dati i valori di X (la variabile v nei grafici sopra per intenderci) e $\theta$ (il vettore dei coefficienti della regressione lineare che dicevamo prima).
La likelihood totale per il vettore di pesi $\beta$ è quindi:
$$
L(\beta) = \prod_{i=1}^{n} P(Y_i \mid x_i)
$$
Sostituendo l'equazione 4 nell'equazione 5 otteniamo:
$$
L(\beta) = \prod_{i=1}^{n} \sigma(\beta^T x^{(i)})^{y^{(i)}} \cdot [1 - \sigma(\beta^T x^{(i)})]^{(1 - y^{(i)})}
$$
L'idea è di stimare i parametri ($\beta$) in modo da massimizzare $L(\beta)$. Tuttavia, per comodità matematica, massimizziamo il logaritmo di $L(\beta)$ e lo chiamiamo log-likelihood:
$$
LL(\beta) = \sum_{i=1}^{n} y^{(i)} \log \sigma(\beta^T x^{(i)}) + (1 - y^{(i)}) \log[1 - \sigma(\beta^T x^{(i)})]
$$
A questo punto, spero che l'obiettivo precedentemente dichiarato sia più chiaro: trovare i migliori parametri di adattamento β nello spazio logit vs variabile, in modo che LL(β) nello spazio probabilità vs variabile sia massimo.
Come si risolve questo problema? Vediamo due modi!
##### Gradient Ascend
Calcoliamo la derivata parziale della funzione LL:
![[Pasted image 20241025165130.png]]
Però dobbiamo calcolarlo per tutti i sample ovviamente, per cui:
![[Pasted image 20241025165317.png]]
Poi aggiorniamo il valore così:
![[Pasted image 20241025165411.png]]
il parametro $\eta$ indica il rate di apprendimento, come nel gradiant descend della linear regression. Lo scegliamo noi, se è troppo grande l'algoritmo non convergerà mai, se è troppo piccolo ci metterà un fottio, ma sarà più preciso.
#### Newton's method
Un altro metodo è quello di Newton, che è pure migliore. Però ora devo andare alla maker faire quindi ne parliamo settimana prossima, ciao.

4
q&a.md
View file

@ -1,4 +0,0 @@
- explain the problem of energy consumption in sensor networks
As sensor run on batteries, energy consumption is a serious problem as we want sensors' batteries to last as long as possible. To achieve a low energy consumption is very important to define good MAC and routing strategies.
For MAC we can use protocols such as S-MAC, allows sensor to sleep most of the time when they are not communicating.
S-MAC